core/model/modx/modfilehandler.class.php
- Package
- modx
\modDirectory
Representation of a directory
Not to be instantiated directly - you should implement your own derivative class.
- Parent(s)
- \modFileSystemResource
Properties

\modFileHandler
$fileHandler= ''
- Type
- \modFileHandler
- Inherited_from
- \modFileSystemResource::$$fileHandler

array
$options= 'array()'
array()Details- Type
- array
- Inherited_from
- \modFileSystemResource::$$options

string
$path= ''
- Type
- string
- Inherited_from
- \modFileSystemResource::$$path
Methods

__construct(
\modFileHandler $fh, string $path, array $options
=
array()
)
:
voidConstructor for modFileSystemResource
Inherited from: \modFileSystemResource::__construct()| Name | Type | Description |
|---|---|---|
| $fh | \modFileHandler | A reference to the modFileHandler object |
| $path | string | The path to the fs resource |
| $options | array | An array of specific options |

chgrp(
mixed $grp
)
:
booleanSets the group permission for the fs resource
Inherited from: \modFileSystemResource::chgrp()| Name | Type | Description |
|---|---|---|
| $grp | mixed |
| Type | Description |
|---|---|
| boolean | True if successful |

chmod(
\octal $mode
)
:
boolean
| Name | Type | Description |
|---|---|---|
| $mode | \octal |
| Type | Description |
|---|---|
| boolean | True if successful |

chown(
mixed $owner
)
:
boolean
| Name | Type | Description |
|---|---|---|
| $owner | mixed |
| Type | Description |
|---|---|
| boolean | True if successful |

create(
string $mode
=
''
)
:
booleanActually creates the new directory on the file system.
| Name | Type | Description |
|---|---|---|
| $mode | string | Optional. The permissions of the new directory. |
| Type | Description |
|---|---|
| boolean | True if successful |

getGroup(
)
:
stringGets the permission group for the fs resource
Inherited from: \modFileSystemResource::getGroup()| Type | Description |
|---|---|
| string | The group name of the fs resource |

getParentDirectory(
boolean $raw
=
false
)
:
\modDirectory | stringGets the parent containing directory of this fs resource
Inherited from: \modFileSystemResource::getParentDirectory()| Name | Type | Description |
|---|---|---|
| $raw | boolean | Whether or not to return a modDirectory or string path |
| Type | Description |
|---|---|
| \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. |

isReadable(
)
:
booleanCheck to see if the fs resource is readable
Inherited from: \modFileSystemResource::isReadable()| Type | Description |
|---|---|
| boolean | True if readable |

isWritable(
)
:
booleanCheck to see if the fs resource is writable
Inherited from: \modFileSystemResource::isWritable()| Type | Description |
|---|---|
| boolean | True if writable |

parseMode(
string $mode
=
''
)
:
booleanParses a string mode into octal format
| Name | Type | Description |
|---|---|---|
| $mode | string |
| Type | Description |
|---|---|
| boolean |

remove(
array $options
=
array()
)
:
booleanRemoves the directory from the file system, recursively removing subdirectories and files.
| Name | Type | Description |
|---|---|---|
| $options | array | Options for removal. |
| Type | Description |
|---|---|
| boolean | True if successful |

rename(
string $newPath
)
:
boolean
| Name | Type | Description |
|---|---|---|
| $newPath | string | The new path for the fs resource |
| Type | Description |
|---|---|
| boolean | True if successful |
\modFile
File implementation of modFileSystemResource
Not to be instantiated directly - you should implement your own derivative class.
- Parent(s)
- \modFileSystemResource
Properties

\modFileHandler
$fileHandler= ''
- Type
- \modFileHandler
- Inherited_from
- \modFileSystemResource::$$fileHandler

array
$options= 'array()'
array()Details- Type
- array
- Inherited_from
- \modFileSystemResource::$$options

string
$path= ''
- Type
- string
- Inherited_from
- \modFileSystemResource::$$path
Methods

__construct(
\modFileHandler $fh, string $path, array $options
=
array()
)
:
voidConstructor for modFileSystemResource
Inherited from: \modFileSystemResource::__construct()| Name | Type | Description |
|---|---|---|
| $fh | \modFileHandler | A reference to the modFileHandler object |
| $path | string | The path to the fs resource |
| $options | array | An array of specific options |

chgrp(
mixed $grp
)
:
booleanSets the group permission for the fs resource
Inherited from: \modFileSystemResource::chgrp()| Name | Type | Description |
|---|---|---|
| $grp | mixed |
| Type | Description |
|---|---|
| boolean | True if successful |

chmod(
\octal $mode
)
:
boolean
| Name | Type | Description |
|---|---|---|
| $mode | \octal |
| Type | Description |
|---|---|
| boolean | True if successful |

chown(
mixed $owner
)
:
boolean
| Name | Type | Description |
|---|---|---|
| $owner | mixed |
| Type | Description |
|---|---|
| boolean | True if successful |

create(
string $content
=
'', string $mode
=
'w+'
)
:
booleanActually create the file on the file system
| Name | Type | Description |
|---|---|---|
| $content | string | The content of the file to write |
| $mode | string | The perms to write with the file |
| Type | Description |
|---|---|
| boolean | True if successful |

getBaseName(
)
:
stringGets the basename, or only the filename without the path, of the file
| Type | Description |
|---|---|
| string | The basename of the file |

getContents(
)
:
stringGet the contents of the file
| Type | Description |
|---|---|
| string | The contents of the file |

getExtension(
)
:
stringGets the file extension of the file
| Type | Description |
|---|---|
| string | The file extension of the file |

getGroup(
)
:
stringGets the permission group for the fs resource
Inherited from: \modFileSystemResource::getGroup()| Type | Description |
|---|---|
| string | The group name of the fs resource |

getLastAccessed(
string $timeFormat
=
'%b %d, %Y %I:%M:%S %p'
)
:
stringGets the last accessed time of the file
| Name | Type | Description |
|---|---|---|
| $timeFormat | string | The format, in strftime format, of the time |
| Type | Description |
|---|---|
| string | The formatted time |

getLastModified(
string $timeFormat
=
'%b %d, %Y %I:%M:%S %p'
)
:
stringGets the last modified time of the file
| Name | Type | Description |
|---|---|---|
| $timeFormat | string | The format, in strftime format, of the time |
| Type | Description |
|---|---|
| string | The formatted time |

getParentDirectory(
boolean $raw
=
false
)
:
\modDirectory | stringGets the parent containing directory of this fs resource
Inherited from: \modFileSystemResource::getParentDirectory()| Name | Type | Description |
|---|---|---|
| $raw | boolean | Whether or not to return a modDirectory or string path |
| Type | Description |
|---|---|
| \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. |

getSize(
)
:
intGets the size of the file
| Type | Description |
|---|---|
| int | The size of the file, in bytes |

isReadable(
)
:
booleanCheck to see if the fs resource is readable
Inherited from: \modFileSystemResource::isReadable()| Type | Description |
|---|---|
| boolean | True if readable |

isWritable(
)
:
booleanCheck to see if the fs resource is writable
Inherited from: \modFileSystemResource::isWritable()| Type | Description |
|---|---|
| boolean | True if writable |

parseMode(
string $mode
=
''
)
:
booleanParses a string mode into octal format
| Name | Type | Description |
|---|---|---|
| $mode | string |
| Type | Description |
|---|---|
| boolean |
- See
- \modFileSystemResource.parseMode

remove(
)
:
booleanDeletes the file from the filesystem
| Type | Description |
|---|---|
| boolean | True if successful |

rename(
string $newPath
)
:
boolean
| Name | Type | Description |
|---|---|---|
| $newPath | string | The new path for the fs resource |
| Type | Description |
|---|---|
| boolean | True if successful |

save(
string $content
=
null, string $mode
=
'w+'
)
:
booleanWrites the content of the modFile object to the actual file.
| Name | Type | Description |
|---|---|---|
| $content | string | Optional. If not using setContent, this will set the content to write. |
| $mode | string | The mode in which to write |
| Type | Description |
|---|---|
| boolean | The result of the fwrite |

setContent(
string $content
)
:
voidTemporarly set (but not save) the content of the file
| Name | Type | Description |
|---|---|---|
| $content | string | The content |

setGroup(
string $grp
)
:
boolean
| Name | Type | Description |
|---|---|---|
| $grp | string |
| Type | Description |
|---|---|
| boolean |
- See
- \chgrp
\modFileHandler
Assists with directory/file manipulation
Properties

array
$config= 'array()'
An array of configuration properties for the class
array()Details- Type
- array

\modContext|null
$context= 'null'
The current context in which this File Manager instance should operate
nullDetails- Type
- \modContext | null
Methods

__construct(
\modX $modx, array $config
=
array()
)
:
voidThe constructor for the modFileHandler class
| Name | Type | Description |
|---|---|---|
| $modx | \modX | &$modx A reference to the modX object. |
| $config | array | An array of options. |

getBasePath(
)
:
stringGet the modX base path for the user.
| Type | Description |
|---|---|
| string | The base path |

getDirectoryFromFile(
string $fileName
)
:
stringGets the directory path for a given file
| Name | Type | Description |
|---|---|---|
| $fileName | string | The path for a file |
| Type | Description |
|---|---|
| string | The directory path of the given file |

isBinary(
string $file
)
:
booleanTells if a file is a binary file or not.
| Name | Type | Description |
|---|---|---|
| $file | string |
| Type | Description |
|---|---|
| boolean | True if a binary file. |

make(
string $path, array $options
=
array(), string $overrideClass
=
''
)
:
mixedDynamically creates a modDirectory or modFile object.
The object is created based on the type of resource provided.
| Name | Type | Description |
|---|---|---|
| $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. |
| Type | Description |
|---|---|
| mixed | The appropriate modFile/modDirectory object |

postfixSlash(
string $path
)
:
stringEnsures that the passed path has a / at the end
| Name | Type | Description |
|---|---|---|
| $path | string |
| Type | Description |
|---|---|
| string | The postfixed path |
\modFileSystemResource
Abstract class for handling file system resources (files or folders).
Not to be instantiated directly - you should implement your own derivative class.
- Children
- \modFile
- \modDirectory
Properties

\modFileHandler
$fileHandler= ''
- Type
- \modFileHandler

array
$options= 'array()'
array()Details- Type
- array
Methods

__construct(
\modFileHandler $fh, string $path, array $options
=
array()
)
:
voidConstructor for modFileSystemResource
| Name | Type | Description |
|---|---|---|
| $fh | \modFileHandler | A reference to the modFileHandler object |
| $path | string | The path to the fs resource |
| $options | array | An array of specific options |

chgrp(
mixed $grp
)
:
booleanSets the group permission for the fs resource
| Name | Type | Description |
|---|---|---|
| $grp | mixed |
| Type | Description |
|---|---|
| boolean | True if successful |

chmod(
\octal $mode
)
:
booleanChmods the resource to the specified mode.
| Name | Type | Description |
|---|---|---|
| $mode | \octal |
| Type | Description |
|---|---|
| boolean | True if successful |

chown(
mixed $owner
)
:
booleanSets the owner for the fs resource
| Name | Type | Description |
|---|---|---|
| $owner | mixed |
| Type | Description |
|---|---|
| boolean | True if successful |

exists(
)
:
booleanCheck to see if the fs resource exists
| Type | Description |
|---|---|
| boolean | True if exists |

getGroup(
)
:
stringGets the permission group for the fs resource
| Type | Description |
|---|---|
| string | The group name of the fs resource |

getParentDirectory(
boolean $raw
=
false
)
:
\modDirectory | stringGets the parent containing directory of this fs resource
| Name | Type | Description |
|---|---|---|
| $raw | boolean | Whether or not to return a modDirectory or string path |
| Type | Description |
|---|---|
| \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. |

getPath(
)
:
stringGet the path of the fs resource.
| Type | Description |
|---|---|
| string | The path of the fs resource |

isLink(
)
:
booleanCheck to see if fs resource is symlink
| Type | Description |
|---|---|
| boolean | True if symlink |

isReadable(
)
:
booleanCheck to see if the fs resource is readable
| Type | Description |
|---|---|
| boolean | True if readable |

isWritable(
)
:
booleanCheck to see if the fs resource is writable
| Type | Description |
|---|---|
| boolean | True if writable |

parseMode(
string $mode
=
''
)
:
\octalParses a string mode into octal format
| Name | Type | Description |
|---|---|---|
| $mode | string | The octal to parse |
| Type | Description |
|---|---|
| \octal | The new mode in octal format |

rename(
string $newPath
)
:
booleanRenames the file/folder
| Name | Type | Description |
|---|---|---|
| $newPath | string | The new path for the fs resource |
| Type | Description |
|---|---|
| boolean | True if successful |