model/modx/modfilehandler.class.php
- package
- modx
- Classes
- modFileHandler
- modFileSystemResource
- modFile
- modDirectory
Description
Assists with directory/file manipulation
\modDirectory
- Extends from
- \modFileSystemResource
- package
- modx
- Methods
- create
- parseMode
- remove
Description
Representation of a directory
Not to be instantiated directly - you should implement your own derivative class.
Methods
create
create(
string $mode
)
:
boolean
Actually creates the new directory on the file system.
Arguments
- $mode
- string
Optional. The permissions of the new directory.
Output
- boolean
- True if successful
Details
- visibility
- public
- final
- false
- static
- false
parseMode
parseMode(
string $mode
)
:
\octal
Parses a string mode into octal format
Arguments
- $mode
- string
The octal to parse
Output
- \octal
- The new mode in octal format
Details
- visibility
- protected
- final
- false
- static
- false
- see
- modFileSystemResource::parseMode
remove
remove(
array $options
=
array
)
:
boolean
Removes the directory from the file system, recursively removing subdirectories and files.
Arguments
- $options
- array
Options for removal.
Output
- boolean
- True if successful
Details
- visibility
- public
- final
- false
- static
- false
\modFile
- Extends from
- \modFileSystemResource
- package
- modx
- Properties
- $content
- Methods
- create
- getBaseName
- getContents
- getExtension
- getLastAccessed
- getLastModified
- getSize
- parseMode
- remove
- save
- setContent
- write
Description
File implementation of modFileSystemResource
Not to be instantiated directly - you should implement your own derivative class.
Properties
$content
string $content = ''
Details
- string
The content of the resource - visibility
- protected
- default
- final
- false
- static
- false
Methods
create
create(
string $content, string $mode
=
w+
)
:
boolean
Actually create the file on the file system
Arguments
- $content
- string
The content of the file to write - $mode
- string
The perms to write with the file
Output
- boolean
- True if successful
Details
- visibility
- public
- final
- false
- static
- false
getBaseName
getBaseName(
)
:
string
Gets the basename, or only the filename without the path, of the file
Output
- string
- The basename of the file
Details
- visibility
- public
- final
- false
- static
- false
getContents
getContents(
)
:
string
Get the contents of the file
Output
- string
- The contents of the file
Details
- visibility
- public
- final
- false
- static
- false
getExtension
getExtension(
)
:
string
Gets the file extension of the file
Output
- string
- The file extension of the file
Details
- visibility
- public
- final
- false
- static
- false
getLastAccessed
getLastAccessed(
string $timeFormat
=
%b %d, %Y %I:%M:%S %p
)
:
string
Gets the last accessed time of the file
Arguments
- $timeFormat
- string
The format, in strftime format, of the time
Output
- string
- The formatted time
Details
- visibility
- public
- final
- false
- static
- false
getLastModified
getLastModified(
string $timeFormat
=
%b %d, %Y %I:%M:%S %p
)
:
string
Gets the last modified time of the file
Arguments
- $timeFormat
- string
The format, in strftime format, of the time
Output
- string
- The formatted time
Details
- visibility
- public
- final
- false
- static
- false
getSize
getSize(
)
:
int
Gets the size of the file
Output
- int
- The size of the file, in bytes
Details
- visibility
- public
- final
- false
- static
- false
parseMode
parseMode(
string $mode
)
:
\octal
Parses a string mode into octal format
Arguments
- $mode
- string
The octal to parse
Output
- \octal
- The new mode in octal format
Details
- visibility
- protected
- final
- false
- static
- false
- see
- modFileSystemResource.parseMode
remove
remove(
)
:
boolean
Deletes the file from the filesystem
Output
- boolean
- True if successful
Details
- visibility
- public
- final
- false
- static
- false
save
save(
string $content
=
null, $mode
=
w+
)
:
mixed
Writes the content of the modFile object to the actual file.
Arguments
- $content
- string
Optional. If not using setContent, this will set the content to write. - $mode
Output
- mixed
- The result of the fwrite
Details
- visibility
- public
- final
- false
- static
- false
setContent
setContent(
string $content
)
:
Temporarly set (but not save) the content of the file
Arguments
- $content
- string
The content
Details
- visibility
- public
- final
- false
- static
- false
write
write(
$content
=
null, $mode
=
w+
)
:
Alias for save()
Arguments
- $content
- $mode
Details
- visibility
- public
- final
- false
- static
- false
- see
- modDirectory::write
\modFileHandler
- package
- modx
- Properties
- $config
- $context
- Methods
- __construct
- getBasePath
- getBaseUrl
- getDirectoryFromFile
- isBinary
- make
- postfixSlash
- sanitizePath
Description
Assists with directory/file manipulation
Properties
$config
$config = 'array'
Details
- visibility
- public
- default
- array
- final
- false
- static
- false
$context
$context = 'null'
Details
- visibility
- public
- default
- null
- final
- false
- static
- false
Methods
__construct
__construct(
\modX $modx, array $config
=
array
)
:
The constructor for the modFileHandler class
Arguments
- $modx
- \modX
&$modx A reference to the modX object. - $config
- array
An array of options.
Details
- visibility
- public
- final
- false
- static
- false
getBasePath
getBasePath(
)
:
string
Get the modX base path for the user.
Output
- string
- The base path
Details
- visibility
- public
- final
- false
- static
- false
getBaseUrl
getBaseUrl(
)
:
string
Get base URL of file manager
Output
- string
- The base URL
Details
- visibility
- public
- final
- false
- static
- false
getDirectoryFromFile
getDirectoryFromFile(
$fileName
)
:
Arguments
- $fileName
Details
- visibility
- public
- final
- false
- static
- false
isBinary
isBinary(
string $file
)
:
boolean
Tells if a file is a binary file or not.
Arguments
- $file
- string
Output
- boolean
- True if a binary file.
Details
- visibility
- public
- final
- false
- static
- false
make
make(
string $path, array $options
=
array, string $overrideClass
)
:
mixed
Dynamically creates a modDirectory or modFile object.
The object is created based on the type of resource provided.
Arguments
- $path
- string
The absolute path to the filesystem resource. - $options
- array
Optional. An array of options for the object. - $overrideClass
- string
Optional. If provided, will force creation of the object as the specified class.
Output
- mixed
- The appropriate modFile/modDirectory object
Details
- visibility
- public
- final
- false
- static
- false
postfixSlash
postfixSlash(
$path
)
:
Arguments
- $path
Details
- visibility
- public
- final
- false
- static
- false
sanitizePath
sanitizePath(
string $path
)
:
string
Sanitize the specified path
Arguments
- $path
- string
The path to clean
Output
- string
- The sanitized path
Details
- visibility
- public
- final
- false
- static
- false
\modFileSystemResource
- package
- modx
- Properties
- $fileHandler
- $options
- $path
- Methods
- __construct
- chgrp
- chmod
- chown
- exists
- getGroup
- getParentDirectory
- getPath
- isLink
- isReadable
- isWritable
- parseMode
- rename
- setGroup
Description
Abstract class for handling file system resources (files or folders).
Not to be instantiated directly - you should implement your own derivative class.
Properties
$fileHandler
\modFileHandler $fileHandler = ''
Details
-
\modFileHandler
A reference to a modFileHandler instance - visibility
- public
- default
- final
- false
- static
- false
$options
array $options = 'array'
Details
- array
An array of file system resource specific options - visibility
- public
- default
- array
- final
- false
- static
- false
$path
string $path = ''
Details
- string
The absolute path of the file system resource - visibility
- protected
- default
- final
- false
- static
- false
Methods
__construct
__construct(
\modFileHandler $fh, string $path, array $options
=
array
)
:
Constructor for modFileSystemResource
Arguments
- $fh
- \modFileHandler
A reference to the modFileHandler object - $path
- string
The path to the fs resource - $options
- array
An array of specific options
Details
- visibility
- public
- final
- false
- static
- false
chgrp
chgrp(
mixed $grp
)
:
boolean
Sets the group permission for the fs resource
Arguments
- $grp
- mixed
Output
- boolean
- True if successful
Details
- visibility
- public
- final
- false
- static
- false
chmod
chmod(
\octal $mode
)
:
boolean
Chmods the resource to the specified mode.
Arguments
- $mode
- \octal
Output
- boolean
- True if successful
Details
- visibility
- public
- final
- false
- static
- false
chown
chown(
mixed $owner
)
:
boolean
Sets the owner for the fs resource
Arguments
- $owner
- mixed
Output
- boolean
- True if successful
Details
- visibility
- public
- final
- false
- static
- false
exists
exists(
)
:
boolean
Check to see if the fs resource exists
Output
- boolean
- True if exists
Details
- visibility
- public
- final
- false
- static
- false
getGroup
getGroup(
)
:
string
Gets the permission group for the fs resource
Output
- string
- The group name of the fs resource
Details
- visibility
- public
- final
- false
- static
- false
getParentDirectory
getParentDirectory(
\<type> $raw
=
false
)
:
\modDirectory/string
Gets the parent containing directory of this fs resource
Arguments
- $raw
- \<type>
Whether or not to return a modDirectory or string path
Output
- \modDirectory/string
- Returns either a modDirectory object of the parent directory, or the absolute path of the parent, depending on whether or not $raw is set to true.
Details
- visibility
- public
- final
- false
- static
- false
getPath
getPath(
)
:
string
Get the path of the fs resource.
Output
- string
- The path of the fs resource
Details
- visibility
- public
- final
- false
- static
- false
isLink
isLink(
)
:
boolean
Check to see if fs resource is symlink
Output
- boolean
- True if symlink
Details
- visibility
- public
- final
- false
- static
- false
isReadable
isReadable(
)
:
boolean
Check to see if the fs resource is readable
Output
- boolean
- True if readable
Details
- visibility
- public
- final
- false
- static
- false
isWritable
isWritable(
)
:
boolean
Check to see if the fs resource is writable
Output
- boolean
- True if writable
Details
- visibility
- public
- final
- false
- static
- false
parseMode
parseMode(
string $mode
)
:
\octal
Parses a string mode into octal format
Arguments
- $mode
- string
The octal to parse
Output
- \octal
- The new mode in octal format
Details
- visibility
- protected
- final
- false
- static
- false
rename
rename(
string $newPath
)
:
boolean
Renames the file/folder
Arguments
- $newPath
- string
The new path for the fs resource
Output
- boolean
- True if successful
Details
- visibility
- public
- final
- false
- static
- false
setGroup
setGroup(
$grp
)
:
Alias for chgrp
Arguments
- $grp
Details
- visibility
- public
- final
- false
- static
- false
- see
- chgrp