CSFileUtils
in package
Tags
Table of Contents
- BOMDATA_BOCU1_V1 = 'FBEE28'
- BOMDATA_BOCU1_V2 = 'FBEE28FF'
- BOMDATA_EBCDIC = 'DD736673'
- BOMDATA_GB18030 = '84319533'
- BOMDATA_SCSU = '0EFEFF'
- BOMDATA_UTF1 = 'F7644C'
- BOMDATA_UTF16_BE = 'FEFF'
- BOMDATA_UTF16_LE = 'FFFE'
- BOMDATA_UTF32_BE = '0000FEFF'
- BOMDATA_UTF32_LE = 'FFFE0000'
- BOMDATA_UTF7_V1 = '2B2F7638'
- BOMDATA_UTF7_V2 = '2B2F7639'
- BOMDATA_UTF7_V3 = '2B2F762B'
- BOMDATA_UTF7_V4 = '2B2F762F'
- BOMDATA_UTF8 = 'EFBBBF'
- BOMTYPE_BOCU1 = 'BOCU-1'
- BOMTYPE_EBCDIC = 'UTF-EBCDIC'
- BOMTYPE_GB18030 = 'GB 18030'
- BOMTYPE_SCSU = 'SCSU'
- BOMTYPE_UNKNOWN = ''
- BOMTYPE_UTF1 = 'UTF-1'
- BOMTYPE_UTF16_BE = 'UTF-16 (Big Endian)'
- BOMTYPE_UTF16_LE = 'UTF-16 (Little Endian)'
- BOMTYPE_UTF32_BE = 'UTF-32 (Big Endian)'
- BOMTYPE_UTF32_LE = 'UTF-32 (Little Endian)'
- BOMTYPE_UTF7 = 'UTF-7'
- BOMTYPE_UTF8 = 'UTF-8'
- CHMOD_AUTO = -1
- CHMOD mode constants
- CHMOD_FILE = 0660
- CHMOD_FOLDER = 0770
- MAX_CHARS_PER_CELL = 32767
- Total number of characters that a cell can contain in Excel
- appendToFile() : bool
- Appends content to a file's content
- checkSecurityId() : bool
- Checks a given security ids validity for the given file path.
- chmod() : bool
- Sets the file system permissions for the path provided
- copy() : bool
- Copies a file or folder to another folder
- deleteFile() : bool
- Deletes a file
- deleteFolder() : bool
- Deletes a folder
- fopen() : resource
- opens a file for file operations
- generateSplitPathForID() : string
- this method generates a split path for a given id. That means, that the folder hirarchy consists of iCharNumber characters for every folder level. Example for ID 453456 with character count 2:
- getAdminFile() : string
- Get a filename from a file which is located relative to the admin directory.
- getBom() : string
- Tries to detect the byte order marker (BOM) of a given file.
- getBomData() : string
- Transforms the specified BOM hex pattern into the corresponding byte representation.
- getBomType() : string
- Tries to detect the byte order marker (BOM) type of a given file.
- getBytes() : int
- Returns the size in bytes for a formatted file size
- getCTime() : string
- Returns the creation date of a given file
- getDownloadURL() : string
- Returns an HTTP Link via a so called FileServer that will deliver that file in a way that the user can download it
- getFile() : CSLocalFile
- Returns the local file stream API object for a given local file path.
- getFileBaseName() : string
- Returns the base name of a file without the folder and without the extension
- getFileName() : string
- Returns the name of a file without the folder but with the extension
- getFileNameAlternative() : string
- Returns an alternate, non-existing name for a given path using a localized "Copy of..." prefix and, if still existing, an incremental postfix.
- getFileServerURL() : string
- Returns an HTTP Link via a so called FileServer that will deliver that file
- getFileSize() : string
- Returns the formatted size of a file
- getFileType() : string
- Returns the file type extensions of a file
- getFolderPath() : string
- Returns the path to the folder a give files resides in
- getIcon() : string
- Returns the path to a file type icon of a given file
- getMaxCharsPerCell() : int
- This method Returns the maximum amount of characters a cell in MS-Excel / CSV can contain
- getModuleFile() : string
- Get a filename from a file which is located relative to the modules directory.
- getMTime() : string
- Returns the modification date of a given file
- getRealPath() : string
- Returns the absolute pysical file system path of a given file or folder
- getRelativePath() : string
- Returns the path to a file from the point of view of another folder
- getSecurityID() : string
- Returns a security id for a given file path
- getSecurityPrefix() : string|null
- Returns the file security prefix.
- getStreamURL() : string
- Returns a direct stream link
- hasBom() : bool
- Detects whether the content of the specified file starts with one of the well-known BOMs (byte order markers).
- highlightFile() : mixed
- highlights the source code in a file and prints the content to the output buffer (or returns it)
- isAbsolutePath() : bool
- checks whether the passed path is an absolute path
- isInFolder() : bool
- Returns true if a given file is within a give folder
- isUploadedFile() : bool
- Check if the given tmp-file path is truly an uploaded file.
- isValidFileName() : bool
- Check a given folder or file name for it's validity.
- isXMLFile() : mixed
- listFolder() : array<string|int, mixed>
- Returns an array with files and folders in a given folder
- lockFile() : void
- locks a file for exclusive access
- md5() : string
- creates an md5 hash for the content of a file
- move() : bool
- Moves a file or folder to another folder
- moveUploadedFile() : bool
- Moves an uploaded file to a new location
- parseIniFile() : array<string|int, mixed>|false
- Parses an ini file and returns it as an array
- printFile() : int
- Prints file content to the output buffer
- printFileAndDie() : void
- Discard any output buffer contents and closes the current session, then streams the file content directly to the client and dies.
- readCSVFile() : array<string|int, mixed>
- Read a csv file into an array
- readExcelXFile() : array<string|int, mixed>
- Reads an excel file that is stored in the xlsx format.
- readExcelXLSXFile() : array<string|int, mixed>
- Reads an excel file that is stored in the xlsx format.
- readExcelXMLFile() : array<string|int, mixed>
- Enter description here.
- readFile() : string
- This function reads a file's content
- readFileAsArray() : array<string|int, mixed>
- This function reads a file's content into an array, each line represents one of this array elements
- readLastLinesOfFile() : array<string|int, mixed>
- This function reads the last lines of file's content into an array, each line represents one of this array elements
- replaceRelativePathsInStyleContent() : string
- Utility method for replacing relative paths in style files to be relative to the base directory.
- stream() : mixed
- Streams the given file and dies
- touchFile() : bool
- Touches a file
- touchFolder() : bool
- Touches a folder
- unlockFile() : bool
- unlocks a locked file
- unzip() : bool
- Unzips a file or folder
- writeCSVFile() : void
- Writes an array into a csv file
- writeExcelXLSXFile() : bool
- Writes an array into a xlsx file
- writeExcelXMLFile() : bool
- Enter description here.
- writeFile() : bool
- Writes a file's content
- zip() : bool
- Zips a file or folder
Constants
BOMDATA_BOCU1_V1
public
mixed
BOMDATA_BOCU1_V1
= 'FBEE28'
Tags
BOMDATA_BOCU1_V2
public
mixed
BOMDATA_BOCU1_V2
= 'FBEE28FF'
Tags
BOMDATA_EBCDIC
public
mixed
BOMDATA_EBCDIC
= 'DD736673'
Tags
BOMDATA_GB18030
public
mixed
BOMDATA_GB18030
= '84319533'
Tags
BOMDATA_SCSU
public
mixed
BOMDATA_SCSU
= '0EFEFF'
Tags
BOMDATA_UTF1
public
mixed
BOMDATA_UTF1
= 'F7644C'
Tags
BOMDATA_UTF16_BE
public
mixed
BOMDATA_UTF16_BE
= 'FEFF'
Tags
BOMDATA_UTF16_LE
public
mixed
BOMDATA_UTF16_LE
= 'FFFE'
Tags
BOMDATA_UTF32_BE
public
mixed
BOMDATA_UTF32_BE
= '0000FEFF'
Tags
BOMDATA_UTF32_LE
public
mixed
BOMDATA_UTF32_LE
= 'FFFE0000'
Tags
BOMDATA_UTF7_V1
public
mixed
BOMDATA_UTF7_V1
= '2B2F7638'
Tags
BOMDATA_UTF7_V2
public
mixed
BOMDATA_UTF7_V2
= '2B2F7639'
Tags
BOMDATA_UTF7_V3
public
mixed
BOMDATA_UTF7_V3
= '2B2F762B'
Tags
BOMDATA_UTF7_V4
public
mixed
BOMDATA_UTF7_V4
= '2B2F762F'
Tags
BOMDATA_UTF8
public
mixed
BOMDATA_UTF8
= 'EFBBBF'
Tags
BOMTYPE_BOCU1
public
mixed
BOMTYPE_BOCU1
= 'BOCU-1'
Tags
BOMTYPE_EBCDIC
public
mixed
BOMTYPE_EBCDIC
= 'UTF-EBCDIC'
Tags
BOMTYPE_GB18030
public
mixed
BOMTYPE_GB18030
= 'GB 18030'
Tags
BOMTYPE_SCSU
public
mixed
BOMTYPE_SCSU
= 'SCSU'
Tags
BOMTYPE_UNKNOWN
public
mixed
BOMTYPE_UNKNOWN
= ''
Tags
BOMTYPE_UTF1
public
mixed
BOMTYPE_UTF1
= 'UTF-1'
Tags
BOMTYPE_UTF16_BE
public
mixed
BOMTYPE_UTF16_BE
= 'UTF-16 (Big Endian)'
Tags
BOMTYPE_UTF16_LE
public
mixed
BOMTYPE_UTF16_LE
= 'UTF-16 (Little Endian)'
Tags
BOMTYPE_UTF32_BE
public
mixed
BOMTYPE_UTF32_BE
= 'UTF-32 (Big Endian)'
Tags
BOMTYPE_UTF32_LE
public
mixed
BOMTYPE_UTF32_LE
= 'UTF-32 (Little Endian)'
Tags
BOMTYPE_UTF7
public
mixed
BOMTYPE_UTF7
= 'UTF-7'
Tags
BOMTYPE_UTF8
public
mixed
BOMTYPE_UTF8
= 'UTF-8'
Tags
CHMOD_AUTO
CHMOD mode constants
public
mixed
CHMOD_AUTO
= -1
Tags
CHMOD_FILE
public
mixed
CHMOD_FILE
= 0660
Tags
CHMOD_FOLDER
public
mixed
CHMOD_FOLDER
= 0770
Tags
MAX_CHARS_PER_CELL
Total number of characters that a cell can contain in Excel
public
mixed
MAX_CHARS_PER_CELL
= 32767
Tags
Methods
appendToFile()
Appends content to a file's content
public
static appendToFile(string $file, string $content) : bool
If the file exists the content will be added to the end of the file, otherwise the file will be created.
Parameters
- $file : string
-
the path to the file
- $content : string
-
the content of the file
Tags
Return values
bool —true, if the file could be written
checkSecurityId()
Checks a given security ids validity for the given file path.
public
static checkSecurityId(string $sFilePath, string $sSecurityId) : bool
Parameters
- $sFilePath : string
-
The path to the file for which the security id should be checked.
- $sSecurityId : string
-
The security id to check for the given file path.
Tags
Return values
bool —True, if the security id is valid, otherwise false.
chmod()
Sets the file system permissions for the path provided
public
static chmod(string $sPath, int $iMode) : bool
Parameters
- $sPath : string
-
The path for file or folder where file system permissions should be applied.
- $iMode : int
-
The mode to be set, based on the available constants CHMOD_AUTO, CHMOD_FILE or CHMOD_FOLDER
Tags
Return values
bool —copy()
Copies a file or folder to another folder
public
static copy(string $source, string $target[, array<string|int, mixed> $arguments = array() ]) : bool
Parameters
- $source : string
-
the path to the file or folder that should be copied
- $target : string
-
the path to the target folder, that should contain the copied file or folder
- $arguments : array<string|int, mixed> = array()
-
additional arguments specifing the copy process
Tags
Return values
bool —true if the copy action was successful, otherwise false.
deleteFile()
Deletes a file
public
static deleteFile(string $file[, bool $validate = true ]) : bool
Parameters
- $file : string
-
the path to the file that should be deleted
- $validate : bool = true
-
whether the file should be checked if it is within CONTENTSERV
Tags
Return values
bool —true on success
deleteFolder()
Deletes a folder
public
static deleteFolder(string $folder[, bool $removeOnlyChildren = false ]) : bool
Parameters
- $folder : string
-
the path to the folder that should be deleted
- $removeOnlyChildren : bool = false
-
if true, only the content of the folder will be deleted
Tags
Return values
bool —true on success
fopen()
opens a file for file operations
public
static fopen(string $file[, string $mode = 'r' ]) : resource
Parameters
- $file : string
-
the file path to the file
- $mode : string = 'r'
-
the file mode to use (@see fopen php function)
Tags
Return values
resource —the file handler
generateSplitPathForID()
this method generates a split path for a given id. That means, that the folder hirarchy consists of iCharNumber characters for every folder level. Example for ID 453456 with character count 2:
public
static generateSplitPathForID(int $iID[, mixed $iCharNumber = 2 ]) : string
/45/4534/453456/453456
Parameters
- $iID : int
-
the id for which to create the split path
- $iCharNumber : mixed = 2
Tags
Return values
string —the splitted path (see example)
getAdminFile()
Get a filename from a file which is located relative to the admin directory.
public
static getAdminFile(string $file) : string
First the project/admin, than the admin.local/admin and if no other is found, the file located admin is returned
Parameters
- $file : string
-
the path to a file relative to the admin folder
Tags
Return values
string —the path of the file relative to the admin directory
getBom()
Tries to detect the byte order marker (BOM) of a given file.
public
static getBom(string $sFilePath) : string
Parameters
- $sFilePath : string
-
An absolute or relative path to file that should be examined.
Tags
Return values
string —One of the BOMDATA_* constants, which represent the hexadecimal notation of the detected BOM. In order to obtain the real BOM bytes, the result should be subsequently passed through the method. If the specified path refers to a non-existent or unreadable file or a directory, the BOMTYPE_UNKNOWN constant is returned. The same applies to files, which are not tagged using a BOM.
getBomData()
Transforms the specified BOM hex pattern into the corresponding byte representation.
public
static getBomData(string $sBomPattern) : string
Parameters
- $sBomPattern : string
-
The BOMDATA_* constant that should be converted into its byte representation.
Tags
Return values
string —The byte representation of the BOM, as it is contained in a file. This could be used for content replacements, etc. -- e.g., to strip the detected BOM from a file.
getBomType()
Tries to detect the byte order marker (BOM) type of a given file.
public
static getBomType(string $sFilePath) : string
Parameters
- $sFilePath : string
-
An absolute or relative path to file that should be examined.
Tags
Return values
string —One of the BOMTYPE_* constants, which represent the human-readable BOM type. As some BOMs have multiple representations for the same character set (.e.g., UTF-7), this method simplifies the process to detect the character set that is associated with a specific BOM. If the specified path refers to a non-existent or unreadable file or a directory, the BOMTYPE_UNKNOWN constant is returned. The same applies to files, which are not tagged using a BOM.
getBytes()
Returns the size in bytes for a formatted file size
public
static getBytes(string $filesize) : int
Parameters
- $filesize : string
-
the filesize
Tags
Return values
int —the bytes.
getCTime()
Returns the creation date of a given file
public
static getCTime(string $file[, string $format = null ]) : string
Parameters
- $file : string
-
the path to the file
- $format : string = null
-
the format the creation date should be using
Tags
Return values
string —the formatted creation date of the file
getDownloadURL()
Returns an HTTP Link via a so called FileServer that will deliver that file in a way that the user can download it
public
static getDownloadURL(string $file[, bool $downloadAsZip = false ][, string $base = 'relative' ][, string $downloadFileName = null ][, bool $downloadAsMacBinary = false ][, string $sDownloadContext = '' ]) : string
Parameters
- $file : string
-
the path to the file relative to the admin directory
- $downloadAsZip : bool = false
-
whether the file should be zipped
- $base : string = 'relative'
-
base of the link can be one of the following values: relative (default), external, internal, realpath
- $downloadFileName : string = null
-
The suggested file name for the download
- $downloadAsMacBinary : bool = false
-
@deprecated Whether the file should have the mac binary format (only available on MAC Servers)
- $sDownloadContext : string = ''
-
The context of the download call. It is used to set the context in the download tracker log and is only available on items with the interface "CS_RECORD_INTERFACE_ITEM_DOWNLOAD_TRACKER".
Tags
Return values
string —$downloadFileName The suggested file name for the download
getFile()
Returns the local file stream API object for a given local file path.
public
static getFile(string $sLocalPath) : CSLocalFile
Parameters
- $sLocalPath : string
-
The local file path, which should be used to initialise the local file stream API object.
Tags
Return values
CSLocalFile —getFileBaseName()
Returns the base name of a file without the folder and without the extension
public
static getFileBaseName(string $file) : string
Parameters
- $file : string
-
the path to the file or the pure file name
Tags
Return values
string —the base name of the file without the folder and without the extension
getFileName()
Returns the name of a file without the folder but with the extension
public
static getFileName(string $file) : string
Parameters
- $file : string
-
the path to the file
Tags
Return values
string —the name of the file without the folder but with the extension
getFileNameAlternative()
Returns an alternate, non-existing name for a given path using a localized "Copy of..." prefix and, if still existing, an incremental postfix.
public
static getFileNameAlternative(string $sOriginalPath) : string
Parameters
- $sOriginalPath : string
-
The file path for which to calculate an alternative.
Tags
Return values
string —The first non-existent "Copy of...(X)" file name in the original file's directory or the original file's name, if it doesn't exist.
getFileServerURL()
Returns an HTTP Link via a so called FileServer that will deliver that file
public
static getFileServerURL(string $file[, int $width = null ][, int $height = null ][, string $base = 'relative' ][, string $format = null ][, string $colorspace = null ][, int $resolution = null ]) : string
Parameters
- $file : string
-
the path to the file relative to the admin directory
- $width : int = null
-
the maximum width of the requested image or null if no limitation should be applied to the width
- $height : int = null
-
the maximum height of the requested image or null if no limitation should be applied to the height
- $base : string = 'relative'
-
- base of the link can be one of the following values: relative (default), external, internal, realpath
- $format : string = null
-
the format of the requested image or null if no change should be applied to the format
- $colorspace : string = null
-
the colorspace of the requested image or null if no change should be applied to the colorspace
- $resolution : int = null
-
the resolution of the requested image or null if no change should be applied to the resolution
Tags
Return values
string —URL of the FileServer Link to the file
getFileSize()
Returns the formatted size of a file
public
static getFileSize(string $file) : string
Parameters
- $file : string
-
the path to the file
Tags
Return values
string —the formatted file size with KB, GB, etc.
getFileType()
Returns the file type extensions of a file
public
static getFileType(string $file[, bool $detectFileExtension = false ]) : string
Parameters
- $file : string
-
the path to the file
- $detectFileExtension : bool = false
-
whether the FileExtension should be detected from the file content if no or no known extension is given
Tags
Return values
string —the file type extension of the file
getFolderPath()
Returns the path to the folder a give files resides in
public
static getFolderPath(string $file) : string
Parameters
- $file : string
-
the path to the file
Tags
Return values
string —the path to the folder of the file
getIcon()
Returns the path to a file type icon of a given file
public
static getIcon(string $file) : string
Parameters
- $file : string
-
the path to the file
Tags
Return values
string —relative path to the file type icon
getMaxCharsPerCell()
This method Returns the maximum amount of characters a cell in MS-Excel / CSV can contain
public
static getMaxCharsPerCell() : int
Tags
Return values
int —the count of characters that can be present
getModuleFile()
Get a filename from a file which is located relative to the modules directory.
public
static getModuleFile(string $file) : string
First the project/modules, than the admin.local/modules and if no other is found, the file located admin/modules is returned
Parameters
- $file : string
-
the path to a file relative to a modules folder
Tags
Return values
string —the path of the file relative to the admin directory
getMTime()
Returns the modification date of a given file
public
static getMTime(string $file[, string $format = null ]) : string
Parameters
- $file : string
-
the path to the file
- $format : string = null
-
the format the modification date should be using
Tags
Return values
string —the formatted modification date of the file
getRealPath()
Returns the absolute pysical file system path of a given file or folder
public
static getRealPath(string $file) : string
Other than the PHP function realpath() this functions returns the path even if the folder or file does not yet exist
Parameters
- $file : string
-
the path to the folder or file
Tags
Return values
string —the absolute path to the file or folder on the physical file system
getRelativePath()
Returns the path to a file from the point of view of another folder
public
static getRelativePath(string $file[, string $rootFolder = "." ]) : string
Parameters
- $file : string
-
the path to the file
- $rootFolder : string = "."
-
the path to the folder that should view the file
Tags
Return values
string —relative path to the file
getSecurityID()
Returns a security id for a given file path
public
static getSecurityID(string $sFilePath) : string
Parameters
- $sFilePath : string
-
the path of a mamfile
Tags
Return values
string —the generated security id
getSecurityPrefix()
Returns the file security prefix.
public
static getSecurityPrefix([string $sProjectName = '' ]) : string|null
Parameters
- $sProjectName : string = ''
-
The project name which should be included in the prefix.
Tags
Return values
string|null —getStreamURL()
Returns a direct stream link
public
static getStreamURL(string $file[, string $fileName = '' ]) : string
Parameters
- $file : string
-
the path to the file which should be streamed
- $fileName : string = ''
-
the optional name of the file of the download dialog
Tags
Return values
string —a FileServer link to download a file
hasBom()
Detects whether the content of the specified file starts with one of the well-known BOMs (byte order markers).
public
static hasBom(string $sFilePath) : bool
Parameters
- $sFilePath : string
-
An absolute or relative path to file that should be examined.
Tags
Return values
bool —TRUE, if the content of the specified file starts with one of the BOMs defined by the BOMDATA_* constants. This usually is an indication of the character set that was used when the file was written (but it's not guaranteed). FALSE, if the specified file is unreadable, does not exist, is a directory or does not contain any known byte order marker.
highlightFile()
highlights the source code in a file and prints the content to the output buffer (or returns it)
public
static highlightFile(string $file[, bool $return = false ]) : mixed
Parameters
- $file : string
-
the path to the source file
- $return : bool = false
-
whether to return the highlighted code or print it to the output buffer
Tags
Return values
mixed —the highlighted code if the $return param is true, otherwise bool true on success or false on failure
isAbsolutePath()
checks whether the passed path is an absolute path
public
static isAbsolutePath(string $path) : bool
Parameters
- $path : string
-
the path to check
Tags
Return values
bool —true if path is absolute otherwise false
isInFolder()
Returns true if a given file is within a give folder
public
static isInFolder(string $file[, mixed $folder = '.' ]) : bool
Parameters
- $file : string
-
the path to the file that should be checked
- $folder : mixed = '.'
Tags
Return values
bool —true if the file is within the folder
isUploadedFile()
Check if the given tmp-file path is truly an uploaded file.
public
static isUploadedFile(string $sSourceTmpFilePath) : bool
The tmp file path is stored in $_FILES[]['tmp_name']
Parameters
- $sSourceTmpFilePath : string
Tags
Return values
bool —isValidFileName()
Check a given folder or file name for it's validity.
public
static isValidFileName(string $fileName) : bool
Filenames must not contain any characters that are not letters, numbers, the full stop symbol, the underscore or the dash. German umlaut letters have been included as well.
Parameters
- $fileName : string
-
file name to validate
Tags
Return values
bool —true/false
isXMLFile()
public
static isXMLFile(mixed $file) : mixed
Parameters
- $file : mixed
Tags
Return values
mixed —listFolder()
Returns an array with files and folders in a given folder
public
static listFolder(string $path[, bool $includeFiles = true ][, bool $includeFolders = true ][, bool $recursive = false ]) : array<string|int, mixed>
Parameters
- $path : string
-
the path to the folder
- $includeFiles : bool = true
-
if true files will be contained in the result
- $includeFolders : bool = true
-
if true folders will be contained in the result
- $recursive : bool = false
-
if true also files and folders from sub folders will be included recursively
Tags
Return values
array<string|int, mixed> —with the files and folders contained
lockFile()
locks a file for exclusive access
public
static lockFile(string $file[, int $timeout = 1000 ]) : void
Parameters
- $file : string
-
the path to a file relative to the admin folder
- $timeout : int = 1000
-
a timeout value (in milliseconds) that specifies how long another process must wait before the file can be accessed when locked
Tags
Return values
void —md5()
creates an md5 hash for the content of a file
public
static md5(string $file) : string
Parameters
- $file : string
-
the path to the file
Tags
Return values
string —the md5 hash for the file content
move()
Moves a file or folder to another folder
public
static move(string $source, string $target) : bool
Parameters
- $source : string
-
the path to the file or folder that should be moved
- $target : string
-
the path to the target folder, that should contain the moved file or folder
Tags
Return values
bool —true on success
moveUploadedFile()
Moves an uploaded file to a new location
public
static moveUploadedFile(string $sSourceTmpFilePath, string $sDestinationFilePath) : bool
Parameters
- $sSourceTmpFilePath : string
-
The temp filename of the uploaded file. $_FILES[]['tmp_name']
- $sDestinationFilePath : string
-
The destination of the moved file.
Tags
Return values
bool —Return TRUE if move action succeeded.
parseIniFile()
Parses an ini file and returns it as an array
public
static parseIniFile(string $sFilePath[, bool $bProcessSections = false ][, int $iScannerMode = INI_SCANNER_NORMAL ]) : array<string|int, mixed>|false
Parameters
- $sFilePath : string
-
The path to the ini file
- $bProcessSections : bool = false
-
By setting the process_sections parameter to true, you get a multidimensional array, with the section names and settings included. The default for process_sections is false
- $iScannerMode : int = INI_SCANNER_NORMAL
-
Can either be INI_SCANNER_NORMAL (default) or INI_SCANNER_RAW. If INI_SCANNER_RAW is supplied, then option values will not be parsed.
Tags
Return values
array<string|int, mixed>|false —The settings are returned as an associative array on success,
printFile()
Prints file content to the output buffer
public
static printFile(string $file[, string $sFileName = '' ]) : int
Parameters
- $file : string
-
The path to the file
- $sFileName : string = ''
-
The filename which should be shown if the stream runs in the background.
Tags
Return values
int —the amount of streamed bytes
printFileAndDie()
Discard any output buffer contents and closes the current session, then streams the file content directly to the client and dies.
public
static printFileAndDie(string $sFilePath[, string $sFileName = '' ]) : void
Parameters
- $sFilePath : string
-
The absolute or relative path to the file to print.
- $sFileName : string = ''
-
The filename which should be shown if the stream runs in the background.
Tags
Return values
void —readCSVFile()
Read a csv file into an array
public
static readCSVFile(mixed $file[, string $delimiter = null ][, string $enclosure = '"' ][, string $fileEncoding = null ][, bool $hasLabels = true ]) : array<string|int, mixed>
The first line is assumed as title row.
Parameters
- $file : mixed
-
the path to a file relative to the admin folder or a CSMamFile-object
- $delimiter : string = null
-
optional string the delimitier that separates the values
- $enclosure : string = '"'
-
optinal string the enclosing charater
- $fileEncoding : string = null
-
the encoding of the CSV-File (The result is UTF-8)
- $hasLabels : bool = true
-
whether the first row contains labels
Tags
Return values
array<string|int, mixed> —an array with arrays, the field names are the keys
readExcelXFile()
Reads an excel file that is stored in the xlsx format.
public
static readExcelXFile(string $sFilePath[, bool $bHasHeaderRow = false ]) : array<string|int, mixed>
Parameters
- $sFilePath : string
-
THe file path to the file.
- $bHasHeaderRow : bool = false
-
If true, the first row in the excel sheet is considered as header row. The header names are used as keys for every value in every row. In case this value is false, the keys are numeric values.
Tags
Return values
array<string|int, mixed> —The data in the excel file as associative array in the format:
array( 'sheet1' => array( [0] => array( [0] => value1 [1] => value2 [2] => value3 ) [1] => array( [0] => value1 [1] => value2 [2] => value3 ) ) 'sheet2' => array( [0] => array( [0] => value1 [1] => value2 [2] => value3 ) [1] => array( [0] => value1 [1] => value2 [2] => value3 ) ) )
or in case of header row
array( 'sheet1' => array( [0] => array( [column1] => value1 [column2] => value2 [column3] => value3 ) [1] => array( [column1] => value1 [column2] => value2 [column3] => value3 ) ) 'sheet2' => array( [0] => array( [column1] => value1 [column2] => value2 [column3] => value3 ) [1] => array( [column1] => value1 [column2] => value2 [column3] => value3 ) ) )
readExcelXLSXFile()
Reads an excel file that is stored in the xlsx format.
public
static readExcelXLSXFile(string $sFilePath[, bool $bHasHeaderRow = false ]) : array<string|int, mixed>
Parameters
- $sFilePath : string
-
THe file path to the file.
- $bHasHeaderRow : bool = false
-
If true, the first row in the excel sheet is considered as header row. The header names are used as keys for every value in every row. In case this value is false, the keys are numeric values.
Tags
Return values
array<string|int, mixed> —The data in the excel file as associative array in the format:
array( 'sheet1' => array( [0] => array( [0] => value1 [1] => value2 [2] => value3 ) [1] => array( [0] => value1 [1] => value2 [2] => value3 ) ) 'sheet2' => array( [0] => array( [0] => value1 [1] => value2 [2] => value3 ) [1] => array( [0] => value1 [1] => value2 [2] => value3 ) ) )
or in case of header row
array( 'sheet1' => array( [0] => array( [column1] => value1 [column2] => value2 [column3] => value3 ) [1] => array( [column1] => value1 [column2] => value2 [column3] => value3 ) ) 'sheet2' => array( [0] => array( [column1] => value1 [column2] => value2 [column3] => value3 ) [1] => array( [column1] => value1 [column2] => value2 [column3] => value3 ) ) )
readExcelXMLFile()
Enter description here.
public
static readExcelXMLFile(string $file[, bool $hasHeaderRow = null ]) : array<string|int, mixed>
..
Parameters
- $file : string
- $hasHeaderRow : bool = null
-
When this parameter is set to TRUE then read the first line has headline, is this parameter FALSE then return this function a numeric array and is this parameter NULL then read the file with auto select
Tags
Return values
array<string|int, mixed> —readFile()
This function reads a file's content
public
static readFile(string $file[, bool $skipBOM = true ]) : string
Parameters
- $file : string
-
the path to the file
- $skipBOM : bool = true
-
whether the file may contain a UTF-8 BOM at the starting of the file which should be skipped
Tags
Return values
string —the content of the file
readFileAsArray()
This function reads a file's content into an array, each line represents one of this array elements
public
static readFileAsArray(string $file) : array<string|int, mixed>
Parameters
- $file : string
-
the path to the file
Tags
Return values
array<string|int, mixed> —the content of the file as array
readLastLinesOfFile()
This function reads the last lines of file's content into an array, each line represents one of this array elements
public
static readLastLinesOfFile(mixed $filePath[, mixed $lines = 10 ]) : array<string|int, mixed>
Parameters
- $filePath : mixed
- $lines : mixed = 10
Tags
Return values
array<string|int, mixed> —the content of the file as array
replaceRelativePathsInStyleContent()
Utility method for replacing relative paths in style files to be relative to the base directory.
public
static replaceRelativePathsInStyleContent(string $sStyleContent, string $sStyleFilePath) : string
Parameters
- $sStyleContent : string
-
The style content which should be checked and replaced.
- $sStyleFilePath : string
-
The path to the style file.
Tags
Return values
string —The style content with the replaced relative paths.
stream()
Streams the given file and dies
public
static stream(string $file[, string $fileName = '' ][, bool $asZip = false ]) : mixed
Parameters
- $file : string
-
the path to the file which should be streamed
- $fileName : string = ''
-
the optional name of the file of the download dialog
- $asZip : bool = false
-
whether the file should be zipped
Tags
Return values
mixed —touchFile()
Touches a file
public
static touchFile(string $file[, mixed $time = null ][, mixed $atime = null ]) : bool
If the file exists, only the MTime is updated. Otherwise the file will also be created.
Parameters
- $file : string
-
the path to the file that should be touched
- $time : mixed = null
- $atime : mixed = null
Tags
Return values
bool —true on success
touchFolder()
Touches a folder
public
static touchFolder(string $path) : bool
If the folder exists, nothing happens. Otherwise the folder will be created.
Parameters
- $path : string
-
the path to the folder that should be created
Tags
Return values
bool —true if the folder was created
unlockFile()
unlocks a locked file
public
static unlockFile(string $file) : bool
Parameters
- $file : string
-
the path to a file relative to the admin folder
Tags
Return values
bool —if unlocked successfully true otherwise false
unzip()
Unzips a file or folder
public
static unzip(string $sourceFile[, string $targetFolder = '' ]) : bool
Parameters
- $sourceFile : string
-
the path to the zip file
- $targetFolder : string = ''
-
the path to the folder to which the zip file should be extracted to
Tags
Return values
bool —true on success
writeCSVFile()
Writes an array into a csv file
public
static writeCSVFile(mixed $mFile, array<string|int, mixed> $aData[, string $sDelimiter = ';' ][, string $sEnclosure = '"' ][, string $sFileEncoding = null ][, bool $bAddTableHeaders = true ]) : void
The first line is assumed as title row.
Parameters
- $mFile : mixed
-
the path to a file relative to the admin folder or a CSMamFile-object
- $aData : array<string|int, mixed>
-
an array with arrays, the field names are the keys
- $sDelimiter : string = ';'
-
optional string the delimiter that separates the values
- $sEnclosure : string = '"'
-
optional string the enclosing character
- $sFileEncoding : string = null
-
the encoding of the CSV-File (The data must be UTF-8)
- $bAddTableHeaders : bool = true
Tags
Return values
void —writeExcelXLSXFile()
Writes an array into a xlsx file
public
static writeExcelXLSXFile(string $sFile, array<string|int, mixed> $aData[, bool|null $bWithHeaderRow = null ]) : bool
Parameters
- $sFile : string
-
The file path
- $aData : array<string|int, mixed>
- $bWithHeaderRow : bool|null = null
Tags
Return values
bool —writeExcelXMLFile()
Enter description here.
public
static writeExcelXMLFile(string $file, array<string|int, mixed> $data[, bool $withHeaderRow = NULL ]) : bool
..
Parameters
- $file : string
- $data : array<string|int, mixed>
- $withHeaderRow : bool = NULL
-
When this parameter is set to TRUE then write the array keys as headline, is this parameter FALSE then write a file without headline and is this parameter NULL then write the file with auto select
Tags
Return values
bool —writeFile()
Writes a file's content
public
static writeFile(string $file, string $content[, bool $addBom = false ]) : bool
If the file exists it will be overwritten, otherwise created.
Parameters
- $file : string
-
the path to the file
- $content : string
-
the content of the file
- $addBom : bool = false
-
if true, adds an utf8 bom
Tags
Return values
bool —true, if the file could be written
zip()
Zips a file or folder
public
static zip(string $source, string $targetFile[, bool $deleteSource = false ][, bool $overwriteExistingTarget = true ][, bool $includeRootFolder = true ]) : bool
Parameters
- $source : string
-
the path to the file or folder that should be zipped
- $targetFile : string
-
the path to the resulting zip file
- $deleteSource : bool = false
-
if true the source will be deleted after the zip creation
- $overwriteExistingTarget : bool = true
-
if the target should exist it will be overwritten
- $includeRootFolder : bool = true
-
the zip file will also contain the source folder
Tags
Return values
bool —true on success
