AdvancedDirectoryHandler
extends VirtualDirectory
in package
Implement virtual folder abstraction handler
This class provides interfaces for folder handling. Use this class to route folder calls on regular urls. On top it provides functions to administrate virtual folders.
Table of Contents
- $affected : array<string|int, mixed>
- List of affected files and directories in recursion
- $context : AppContext|Request|CronJob|CommandLineContext
- Storage for current global context
- $db : array<string|int, mixed>
- Database connections
- $domains : array<string|int, mixed>|null
- Buffer for domain objects
- $hooks : array<string|int, mixed>|null
- The hooks buffer
- $link_cache : array<string|int, mixed>|null
- Buffer The resolved links buffer
- $log_template : string
- The template for log messages in ::Log()
- $plugins : array<string|int, mixed>
- The plugin buffer
- $plugins_active : bool
- $relations : array<string|int, mixed>|null
- Buffer tree This is the local storage of relation elements
- $resolver_link_cache : array<string|int, mixed>|null
- Buffer The resolved links buffer
- $size_unit : array<string|int, mixed>
- Available file size short codes
- CalculateFolderSize() : array<string|int, mixed>
- Calculate size of a specific folder use a recursive working function to calculate a folder size
- CallExecutable() : Result
- Execute a system command Uses installed executable to perform a system call
- CallHook() : bool
- Call hook
- CheckAccess() : Result
- Check access helper function Check access permission on folder by specific user and level Has a call to the post check hook that can be used for extended validations. e.g. for a details subscription
- Chmod() : bool
- Change the permissions of a file
- ClearCache() : void
- Clear the static cache
- ClearFolderRelations() : void
- Context() : AppContext|Request|CronJob|CommandLineContext|null
- Get/Set the global context
- CopyFile() : Result
- Copy file Copy a single file with obtaining lock on index before
- CopyFolder() : Result
- Copy folder contents
- CopyFoldersTo() : Result
- Copy folders Copy a set of folders to target
- CopyRelation() : Result
- Function to copy a relation by id to a new target folder
- CreateFolder() : Result
- Create a regular folder
- CreateProject() : Result
- Create a project storage folder
- CreateStorage() : Result
- Create a storage folder
- CreateTaskProject() : Result
- Create a task storage folder
- DataBase() : DBAL|null
- Debug() : bool
- log debug object writs a formatted log message including back trace to the global log file
- DecodeJson() : Result
- Parse json from string to object or assoc
- DecodeJsonFile() : Result
- Parse json from file to object or assoc
- DeleteFile() : bool
- Deletes single file This method deletes a single file, it will wait when the system is in git lock mode
- DeleteRelation() : Result
- Delete relation Delete a single content or extension relation from folder by given id.
- Display() : Result
- Display rendered template
- Display404() : void
- Show 404 page
- DisplayLogin() : Result
- display login form provide the registered template login formular
- DropFolder() : array<string|int, mixed>
- Delete a full folder
- EncodeJson() : Result
- Serialize a given input to json representation
- ExtractExtension() : bool|string
- Extract file extension
- ExtractFileName() : string
- Extract file name
- ExtractFolder() : string
- Extract folder path from root
- ExtractFolderName() : string
- Extract folder name from root
- FetchRelations() : array<string|int, Relation>|array<string|int, stdClass>
- Fetch relations
- FileExists() : bool|string
- Check if file exists
- FilterFolderFilesByModificationTime() : Result
- Get a list of files that are either older or newer a certain time point
- GenerateUUIDv4() : string
- Generate an unique id
- GetDomain() : Domain|null
- Get domain
- GetDomainConfig() : Result
- Get the domain configuration
- GetDomains() : Result
- Get list of domains
- GetFolder() : Result
- Get a folder
- GetFolderObject() : FolderTree|Folder|null
- get a folder use a system path to get the corresponding folder
- GetFolderRelations() : object
- Get Assoc list of assignment Get a single project list with relation identifications
- GetFolderTreeElement() : stdClass
- get a folder element use a system path to get the corresponding folder
- GetFolderTreeElements() : mixed|array<string|int, FolderTree>
- Get the folder tree get the full featured recursive folder tree, this method is cached
- GetFolderTreeRoots() : array<string|int, object>
- get the folder tree root nodes get the full featured recursive folder tree, this method is cached
- GetLock() : Result
- Obtain lock try to obtain the lock indicated by lock file in var
- GetObjectLock() : bool
- Get lock on certain object
- GetRelationFolderById() : array<string|int, mixed>|null
- Get a relation folder by relation id in search
- HandleMultipleAssignments() : Result
- Handle multiple assignment
- HandleMultipleUploads() : Result
- Handle uploads
- HasAccess() : Result
- Test if has access Test access permission on folder by specific user and level
- Is() : string|null
- Test if path is valid virtual directory this function can't resolve bot opt links, they must be mapped before
- IsEmptyDir() : bool|null
- Is empty folder
- KnownPlugins() : array<string|int, Plugin>
- Get the known plugins
- ListFiles() : array<string|int, mixed>
- list files Iterate over directory and list the found files
- ListFolders() : array<string|int, mixed>
- List folder names in certain root folder
- ListIdFiles() : array<string|int, mixed>
- Find file ids
- Log() : bool
- log object writs a formatted log message including back trace to the global log file
- MemoryBytesReadable() : string
- Memory readable Convert size of bytes in human-readable units
- MkFolder() : string|null
- Create folder path
- MoveFoldersTo() : Result
- Move folders Move a set of folders to target that is not inside of one of the targets
- MoveRelation() : Result
- Function to move a relation by id to a new target folder
- OpenProject() : Project|null
- Open a project folder
- OpenStorage() : Storage|null
- Open a storage folder
- OpenTaskProject() : TaskProject|null
- Open a task project
- OptimizedLinkToPath() : Link|null
- Resolve link Back resolve a optimized link
- PathToOptimizedLink() : string
- create optimized link get a optimized link based on the given language and the base folder.
- Plugin() : Plugin|null
- Get plugin
- PluginsActive() : void
- ReadCsv() : Result
- Read a CSV file to local storage
- ReadFile() : Result
- Read a single file
- ReadFixedColumnFile() : Result
- Read file with fixed column width
- ReadFolder() : array<string|int, File>
- Read folder
- RegisterExistingContent() : Result
- Assign content to folder
- RegisterRelation() : Result
- Register a new relation Adds a new relation to a content into an existing virtual folder
- RenameFolderOrFile() : Result
- Rename folder or file
- Render503() : void
- Handle the 503 response
- ResolveDomain() : Domain|null
- Resolve hostname/FQDN to system domain
- RevokeLock() : Result
- release lock try to release the lock indicated by lock file in var
- RevokeObjectLock() : Result
- Revoke dedicated object lock
- SaveDomainConfig() : Result
- Store the domain configuration
- SelfLockedOrOpen() : bool
- ServeRequest() : Response
- serve request parse the given request and send fitting http response
- ServiceDeepLink() : string|null
- Build deep link to a certain service
- StoreEncodedJson() : Result
- Serialize a given input and store it
- StripQueryAndAnchor() : string
- Extract file name
- SysLog() : bool
- Log message
- TaskProjectDeepLink() : string|null
- Create a task board deep link
- TryGetLock() : bool
- Obtain lock with retry
- UpdateRelation() : Result
- Change relation Update a content relation and when defined, also the assigned content.
- Version() : string
- VersionStringToNumber() : string
- Convert version number Converts the given number to a unified string e.g. 'v1.234.33' will become 102340033
- Warn() : bool
- warn level log object writs a formatted log message including back trace to the global log file
- WriteCsv() : Result
- Write an array of entries to csv file
- WriteFile() : bool
- Write string to file
- RegisterPlugins() : void
- Register plugins
- CalculateFolderSizeRecurse() : bool
- Helper function to calculate size Recursively calculate size of a specific folder
- copyFoldersRecursive() : Result|null
- Helper to recursively copy a folder
- decrypt() : string
- Decrypt data
- DropFolderRecurse() : bool
- Delete a folder completely this method is the recursion helper for DropFolder()
- encrypt() : string
- Encrypt data
- execCopyMoveRelation() : Result
- Move or, copy a relation with content
- filterFetchRelations() : array<string|int, mixed>
- Find a set of relations in a certain folder defined by filter set
- moveFoldersRecursive() : Result
- Move the source folder to target
- parseKeyFile() : string|array<string|int, mixed>|null
- postProcessDisplay() : void
- Post process
- resolveErrorTemplate() : Result
- Fetch the corresponding error template by code
Properties
$affected
List of affected files and directories in recursion
private
static array<string|int, mixed>
$affected
= array()
The list of paths
$context
Storage for current global context
private
static AppContext|Request|CronJob|CommandLineContext
$context
= null
$db
Database connections
private
static array<string|int, mixed>
$db
= []
$domains
Buffer for domain objects
private
static array<string|int, mixed>|null
$domains
= null
$hooks
The hooks buffer
private
static array<string|int, mixed>|null
$hooks
= null
$link_cache
Buffer The resolved links buffer
private
static array<string|int, mixed>|null
$link_cache
= null
A list of resolved links
$log_template
The template for log messages in ::Log()
private
static string
$log_template
= "Called from LINE %s IN Script: %s\n"
The template
$plugins
The plugin buffer
private
static array<string|int, mixed>
$plugins
= array()
$plugins_active
private
static bool
$plugins_active
= true
$relations
Buffer tree This is the local storage of relation elements
private
static array<string|int, mixed>|null
$relations
= null
A list of relation elements
$resolver_link_cache
Buffer The resolved links buffer
private
static array<string|int, mixed>|null
$resolver_link_cache
= null
A list of resolved links
$size_unit
Available file size short codes
private
static array<string|int, mixed>
$size_unit
= array('b', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb')
Used in the readable form
Methods
CalculateFolderSize()
Calculate size of a specific folder use a recursive working function to calculate a folder size
public
static CalculateFolderSize(string $folder) : array<string|int, mixed>
Parameters
- $folder : string
-
The path to calculate the size of
Return values
array<string|int, mixed> —An assoc structure holding the folder information
CallExecutable()
Execute a system command Uses installed executable to perform a system call
public
static CallExecutable(string $cmd[, string $folder = '' ][, string $outfile = '' ]) : Result
Parameters
- $cmd : string
-
The command to execute
- $folder : string = ''
-
The working directory
- $outfile : string = ''
-
Optional output file of the call result
Return values
Result —A system result object
CallHook()
Call hook
public
static CallHook(string $name[, mixed|Result|BaseContent &$returns = false ][, mixed|BaseContent &$parameter = null ]) : bool
Calls the interfaces and plugins that are registered on this hook
Available system hooks are:
OnClearAllCache Called when all system caches are cleared at once, has no given argument
OnIndex Called in search index cron job. Has a reference to the job and the list of indexed elements. $parameter contains the content type (ct), the list of changes (list) and the name of the plugin (handler)
OnNewIndex Called in Cache::RecreateIndex with list of files inside the storage folder.
OnSyncronize Called on sync. Gets the list of changed files based on the history buffer. Arguments are similar to OnNewIndex.
RequestOnUrlParsed Called in request constructor, can be used to modify the request itself and the parsed url. Has a reference to the request and the parsed url
OnGetEntityAttributes Called in entity attribute loader. Can be used to modify the whole entity object e.g. add custom fields or tabs.
OnLoadEntityFormPreset Called when using the widget method to get a content type preset. Call is Widget::loadEntityFormPreset $returns is the parsed content type object with resolved attributes.
OnRegisterWidgetIncludes Called on TemplateEngine::renderExtension. Gets as argument the includes list in $param->returns
OnBasketLoadFieldPresetStatus Called in Basket::LoadFieldPresetStatus. Gets as argument the list of available status switches in $param->returns These include a label, value and a set of fields
OnDeleteContent Called in BaseContent when successfully deleted. Gets a reference to the status object and the deleted object. State is referenced in $returns, the deleted object in $parameter
OnAddOrUpdateContent Called in BaseContent when successfully updated or, created. Gets a reference to the status object and the object. State is referenced in $returns, the changed object in $parameter
OnBeforeAddOrUpdateContent Called in base content right before the saver operation State is referenced in $returns, the changed object in $parameter
OnBeforeUserAdminSave Called before saving user data. Gets a reference to the user data payload and a result object.
OnAfterUserAdminSave Called after saving user data. Gets a reference to the user, extras and the payload.
OnUserAdminLoad Called in users widget, when loading own user data (loadSingle). Gets return data and the widget as argument. $returns contains the plain user object, $parameter is a reference to the user widget.
OnUserOwnLoad Called in users widget, when loading own user data (LoadOwn, SendGoogleAuthMail). Gets return data and the widget as argument. $returns contains the plain user object, $parameter is a reference to the user widget.
BasketChangeStatus Hook is called when basket status was changed successfully. $returns contains reference to a system result object. $parameter is an object with the basket instance in key 'basket' and the changes in key 'payload' plus the language
OnBeforeConvertBasketToTask Called right before converting basket to task, has information about the basket and the payload for the new task
OnInitTaskWidget Called in project tasks widget after preparation of data in init call The returns contains an array with the preset data, parameter is the original user request
OnPrepareSiteMapLinks Called in site map generator with returns as result object and $parameter filled with list of links
OnProjectLoadEmployeeRoles Called in project widget when loading employee roles, $returns is the list of roles
OnAfterSendMail Called after successful sending email
OnBeforeResendSendMail Called before sending email to customer (again)
OnAfterPermissionCheck Called in check access to directory, The argument is of type AccessHookArgument, the result a result
OnGetAccessList Called when fetching the user session as last step. Arguments are the response and the user object
OnAfterBasketRegisterUser Called in basket widget after registration of basket is done. Arguments are the result object and an array with user_id and payload as values
OnPreImportContents Called when executing the import cronjob Argument is a file entry after the unzip process
OnRenameFolder Called when renaming the folder by short attribute update or when moving it entirely Called with Result object as return and a FolderMoveHookArgument as parameter
OnDisplay404 Called right before serving the 404 page. Allows the plugins to do some checks before. Argument is the Request object, return is a result object.
OnAddOrUpdateTask Called in task widget on create or update of task Called with Result object as return and a Task as parameter
OnAddService Called on create new service Returns is a result object and param is class with relation and payload
OnCleanupGarbage Called in garbage collect cron job Called with Result object as return and a Job as parameter
OnGetLoginRedirectUrl Called in the getter for the redirect url after successful login Called with Result object as return and the original request url as parameter
OnAfterRelationDelete Called after relation was deleted Called with Result object as return and the combination of relation and content as parameter
OnExecuteSearchUser Call in user search handler Gets the result object nd the search parameters as arguments
OnGetSearchFieldsUser Called after fetch user fields for search The returns argument is the fields of the user
OnUserStatusChange Called after the user active status is change but before saving the user Param is array with user from and target status
OnAfterUserLoginByPassword Called after user password check, param is object with user, credentials and a found indication
OnAfterUserRegisterSession Called after session registration, this is the point where the user is actually logged in Param is the user object.
OnPreUserRegisterSession Called before session registration is done, param is the user object
OnMapArrayIncludes Called after static assets are parsed in template handling Param is the list of links and the result object
OnRenderLoginExtraPre / OnRenderLoginExtra Called on rendering the login template, Response my be usd to add an additional html content
OnAfterRestUserPassword Called after password reset, with arguments result and the user object
OnSearchRelationAttributeList Called in relation attribute search handler when a service related attribute list is queried Parameter is the action with post body payload and the language
OnEmployeeAssignmentStatusChange Called when the assignment status of an employee is changed. Param are the task and the result object
OnBeforeRegisterUser Called on before the user is registered, can be used to modify the user data upfront
OnAfterRegisterUser Called after registration of user was done, param is the user itself
OnBeforeMarkSubscriptionForSwitch Called before users subscription should be changed, param is the user and returns is the result object
OnAfterMarkSubscriptionForSwitch Called when users subscription should be changed, param is the user and returns is the result object
OnMarkSubscriptionForTermination Called when users subscription should be changed, param is the user and returns is the result object
OnNewsletterUserRequiresNotification Called right before new newsletters are queued for a user, the argument is a class with the user and th related newsletter object
OnCronJobRegistered On new cron job from table. Argument is the cron job instance
OnCronJobCompleted On complete cron job from table. Argument is the cron job instance
OnCronJobStarted On start cron job from table. Argument is the cron job instance
OnCronJobProgressChanged Called when the progress was changed and persisted. Argument is the cron job
OnAfterSendMail After email was send, param is the email instance
OnMailRegistered Right after email was registered for sending by cronjob. Param is the email instance
Parameters
- $name : string
-
Name of hook
- $returns : mixed|Result|BaseContent = false
-
Return reference, regularly a Result object
- $parameter : mixed|BaseContent = null
-
Secondary argument, use to add additional information for the call
Return values
bool —CheckAccess()
Check access helper function Check access permission on folder by specific user and level Has a call to the post check hook that can be used for extended validations. e.g. for a details subscription
public
static CheckAccess(Folder $folder, User|null $user[, string $op = 'view' ][, int|string|null $relation = null ]) : Result
Parameters
- $folder : Folder
-
Virtual directory folder
- $user : User|null
-
A system user object, is null for not logged users
- $op : string = 'view'
-
A registered system operation
- $relation : int|string|null = null
-
The relation id
Return values
Result —A default system result object
Chmod()
Change the permissions of a file
public
static Chmod(string $file, int $octal) : bool
Parameters
- $file : string
- $octal : int
Return values
bool —ClearCache()
Clear the static cache
public
static ClearCache() : void
Return values
void —ClearFolderRelations()
public
static ClearFolderRelations() : void
Return values
void —Context()
Get/Set the global context
public
static Context([AppContext|null $context = null ]) : AppContext|Request|CronJob|CommandLineContext|null
Parameters
- $context : AppContext|null = null
Return values
AppContext|Request|CronJob|CommandLineContext|null —CopyFile()
Copy file Copy a single file with obtaining lock on index before
public
static CopyFile(string $source, string $target[, bool $override = true ]) : Result
Parameters
- $source : string
-
Absolute path to source
- $target : string
-
Absolute path to target
- $override : bool = true
-
Override forced even if file names are equal
Return values
Result —A system result object
CopyFolder()
Copy folder contents
public
static CopyFolder(string $source, string $target[, bool $override = true ]) : Result
This method copies the source folder to the target folder path. The folder itself is not copied but all of its contents. This method creates the target folder if it is not present.
Parameters
- $source : string
-
The source folder destination
- $target : string
-
The target folder name
- $override : bool = true
-
Override forced even if file names are equal
Return values
Result —A system result object
CopyFoldersTo()
Copy folders Copy a set of folders to target
public
static CopyFoldersTo(string $target, array<string|int, string> $folders) : Result
Parameters
- $target : string
-
Target virtual folder path
- $folders : array<string|int, string>
-
A list of folders
Return values
Result —A system result object
CopyRelation()
Function to copy a relation by id to a new target folder
public
static CopyRelation(string $id, array<string|int, mixed> $data[, bool $no_check = false ]) : Result
Parameters
- $id : string
-
The relation id
- $data : array<string|int, mixed>
-
The relation update data
- $no_check : bool = false
-
Flag to skip checks
Return values
Result —CreateFolder()
Create a regular folder
public
static CreateFolder(string $dir, array<string|int, mixed> $data) : Result
Parameters
- $dir : string
-
The path to the folder
- $data : array<string|int, mixed>
-
The content
Return values
Result —The creation result
CreateProject()
Create a project storage folder
public
static CreateProject(string $dir, array<string|int, mixed> $data) : Result
Parameters
- $dir : string
-
The path to the folder
- $data : array<string|int, mixed>
-
The content
Return values
Result —The create result
CreateStorage()
Create a storage folder
public
static CreateStorage(string $dir, array<string|int, mixed> $data) : Result
Parameters
- $dir : string
-
The path to the folder
- $data : array<string|int, mixed>
-
The content
Return values
Result —The creation result
CreateTaskProject()
Create a task storage folder
public
static CreateTaskProject(string $dir, array<string|int, mixed> $data) : Result
Parameters
- $dir : string
-
The path to the folder
- $data : array<string|int, mixed>
-
The content
Return values
Result —The create result
DataBase()
public
static DataBase(string $name) : DBAL|null
Parameters
- $name : string
Return values
DBAL|null —Debug()
log debug object writs a formatted log message including back trace to the global log file
public
static Debug(mixed $object) : bool
Parameters
- $object : mixed
-
The object to be logged
Return values
bool —DecodeJson()
Parse json from string to object or assoc
public
static DecodeJson(string $data[, bool $mode = true ][, array<string|int, mixed>|string|null $crypt = null ]) : Result
Use the json parse function to decode a string to assoc or object It will use the given code in crypt to decrypt or fall back to system key
Parameters
- $data : string
-
The payload to decode
- $mode : bool = true
-
Parse as assoc or object, default is true and therefor assoc array
- $crypt : array<string|int, mixed>|string|null = null
-
The key or, an array with cipher, key and the iv
Return values
Result —A default system result object
DecodeJsonFile()
Parse json from file to object or assoc
public
static DecodeJsonFile(string $path[, bool $mode = true ][, string|null $crypt = null ]) : Result
Use the json parse to fetch text data from a given path and return it as object with assoc or object payload
Parameters
- $path : string
-
The absolute path to a certain storage file
- $mode : bool = true
-
Parse as assoc or object, default assoc
- $crypt : string|null = null
-
Decrypt string before parsing
Return values
Result —A default system result object
DeleteFile()
Deletes single file This method deletes a single file, it will wait when the system is in git lock mode
public
static DeleteFile(string $path) : bool
Parameters
- $path : string
-
The target file path
Return values
bool —True on success otherwise false
DeleteRelation()
Delete relation Delete a single content or extension relation from folder by given id.
public
static DeleteRelation(string $id, string $path[, bool $with_content = false ][, string $type = 'content' ]) : Result
Parameters
- $id : string
-
A relation primary id
- $path : string
-
Relative parent folder path
- $with_content : bool = false
-
When content and true delete the content itself
- $type : string = 'content'
-
The type: content or relation
Return values
Result —A system result object
Display()
Display rendered template
public
static Display(string $path, Request $request) : Result
Provide the rendered template encapsulated as result object values Render all contents of the given path using the linked template and assigned contents. Will use Hook::CustomContentList of template when defined and registered in folder configuration.
Parameters
- $path : string
-
Path to system folder tree entry
- $request : Request
-
A system http request object
Return values
Result —A system result object
Display404()
Show 404 page
public
static Display404(string $path, Request $request, Response $res) : void
Display a not found response, does different output per http/ajax request Hs a hook provided as last resort that allows plugins to do some checks before display the 404
Parameters
Return values
void —DisplayLogin()
display login form provide the registered template login formular
public
static DisplayLogin(string $path, Request $request) : Result
Parameters
- $path : string
-
Path to system folder tree entry
- $request : Request
-
A system http request object
Return values
Result —A system result object
DropFolder()
Delete a full folder
public
static DropFolder(string $folder[, bool $full = false ]) : array<string|int, mixed>
this method clears or delete a folder recursively, side effect will fill list of delete folders and files
Parameters
- $folder : string
-
The path to delete
- $full : bool = false
-
Also remove the root folder
Return values
array<string|int, mixed> —List of deleted folders and files
EncodeJson()
Serialize a given input to json representation
public
static EncodeJson(mixed $data[, int $mode = JSON_PRETTY_PRINT ][, array<string|int, mixed>|string|null $crypt = null ]) : Result
use the json parse function to decode an assoc or object
Parameters
- $data : mixed
-
The payload to encode
- $mode : int = JSON_PRETTY_PRINT
-
Serialize readable or not formatted
- $crypt : array<string|int, mixed>|string|null = null
-
Encrypt key or, array with key cipher and iv
Return values
Result —A default system result object
ExtractExtension()
Extract file extension
public
static ExtractExtension(string $path) : bool|string
May return false if no extension could be found
Parameters
- $path : string
-
A complete file path
Return values
bool|string —The file extension or, false if not matched
ExtractFileName()
Extract file name
public
static ExtractFileName(string $path[, bool $without_extension = false ]) : string
Parameters
- $path : string
-
A complete file path
- $without_extension : bool = false
Return values
string —The file name
ExtractFolder()
Extract folder path from root
public
static ExtractFolder(string $path) : string
With input /var/www/school/test.json will result in /var/www/school/
Parameters
- $path : string
-
A complete file path
Return values
string —The file root folder
ExtractFolderName()
Extract folder name from root
public
static ExtractFolderName(string $path) : string
Parameters
- $path : string
-
A complete file path
Return values
string —The file root folder
FetchRelations()
Fetch relations
public
static FetchRelations(FolderTree $folder, string $language[, bool $plain = true ]) : array<string|int, Relation>|array<string|int, stdClass>
Load relation contents using search and resolve them by template positions if defined. Can be used to resolve as object or as relation instance.
Parameters
- $folder : FolderTree
-
A folder tree object
- $language : string
-
The request language for resolving
- $plain : bool = true
-
When set to true, convert the relation to raw object
Return values
array<string|int, Relation>|array<string|int, stdClass> —A list of relations
FileExists()
Check if file exists
public
static FileExists(string $fileName[, bool $caseSensitive = true ]) : bool|string
Does check if a file is existing, will also check if the file exists as lower case by glob as fallback.
Parameters
- $fileName : string
-
The path to the file
- $caseSensitive : bool = true
-
Use case-sensitive path, defaults to true
Return values
bool|string —File exists
FilterFolderFilesByModificationTime()
Get a list of files that are either older or newer a certain time point
public
static FilterFolderFilesByModificationTime(string $root, int $timestamp[, bool $older = true ]) : Result
Parameters
- $root : string
-
The start point for the recursion
- $timestamp : int
-
The time point to flip
- $older : bool = true
-
When true result list files are older than the time stamp otherwise newer
Return values
Result —A system result object containing the files
GenerateUUIDv4()
Generate an unique id
public
static GenerateUUIDv4() : string
Return values
string —GetDomain()
Get domain
public
static GetDomain([int|string|null $id = null ]) : Domain|null
Get a single domain setup by id, when the id is falsy the first one will be returned Search can be a number or a string
Parameters
- $id : int|string|null = null
-
An index or, a domain id
Return values
Domain|null —The found domain or null
GetDomainConfig()
Get the domain configuration
public
static GetDomainConfig() : Result
Return values
Result —GetDomains()
Get list of domains
public
static GetDomains([bool $sort = false ]) : Result
Parameters
- $sort : bool = false
-
When set to true the list will be sorted by prio
Return values
Result —A system result object
GetFolder()
Get a folder
public
static GetFolder(string $path[, string|null $language = null ][, bool $as_folder = false ]) : Result
Use a system path to get the corresponding folder. The given path must be relative to the storage folder
Parameters
- $path : string
-
A virtual directory folder path (tarting /and starting "folder/" will be removed, trailing / will be added
- $language : string|null = null
-
The request language code for resolving properties
- $as_folder : bool = false
-
As folder object
Return values
Result —A system result object with folder when found
GetFolderObject()
get a folder use a system path to get the corresponding folder
public
static GetFolderObject(string $path[, string|null $language = null ][, bool $as_folder = false ]) : FolderTree|Folder|null
Parameters
- $path : string
-
Virtual directory folder path
- $language : string|null = null
-
The request language code
- $as_folder : bool = false
-
As folder object
Return values
FolderTree|Folder|null —A system folder object with folder when found
GetFolderRelations()
Get Assoc list of assignment Get a single project list with relation identifications
public
static GetFolderRelations(string|int $id, string $root) : object
Parameters
- $id : string|int
-
Path to folder object
- $root : string
-
Path to projects root
Return values
object —The found project
GetFolderTreeElement()
get a folder element use a system path to get the corresponding folder
public
static GetFolderTreeElement(string $path[, string|null $language = null ]) : stdClass
Parameters
- $path : string
-
Virtual directory folder path
- $language : string|null = null
-
The request language code
Return values
stdClass —A system folder tree element or null when not found
GetFolderTreeElements()
Get the folder tree get the full featured recursive folder tree, this method is cached
public
static GetFolderTreeElements([string|null $language = null ][, string $root = '' ][, bool $full = false ]) : mixed|array<string|int, FolderTree>
Parameters
- $language : string|null = null
-
The request language code
- $root : string = ''
-
An alternative folder start point
- $full : bool = false
-
When set to true, return with content relations
Return values
mixed|array<string|int, FolderTree> —A recursive folder tree object list
GetFolderTreeRoots()
get the folder tree root nodes get the full featured recursive folder tree, this method is cached
public
static GetFolderTreeRoots([string $language = null ][, string $root = '' ]) : array<string|int, object>
Parameters
- $language : string = null
-
The request language code
- $root : string = ''
-
An alternative folder start point
Return values
array<string|int, object> —A plain list of serialized folder entries
GetLock()
Obtain lock try to obtain the lock indicated by lock file in var
public
static GetLock() : Result
Return values
Result —A default system result object
GetObjectLock()
Get lock on certain object
public
static GetObjectLock(BaseContent $content) : bool
Lock could be obtained, it will return true otherwise false. Uses the system default method "in memory"
Parameters
- $content : BaseContent
-
A system content
Tags
Return values
bool —GetRelationFolderById()
Get a relation folder by relation id in search
public
static GetRelationFolderById( $id[, array<string|int, mixed> $types = array('extension', 'relation', 'amountrelation') ]) : array<string|int, mixed>|null
Parameters
Return values
array<string|int, mixed>|null —HandleMultipleAssignments()
Handle multiple assignment
public
static HandleMultipleAssignments(array<string|int, mixed> $payload) : Result
Handle the assignment of contents to a certain contents attribute. For example an articles multiple images attribute
Parameters
- $payload : array<string|int, mixed>
-
Set of content data with configuration content.type string The content type content.id int The content id files array Set of uploaded files with path and name attribute string Name of the attribute to assign to data_type string The type of asset to create
Return values
Result —A system result object
HandleMultipleUploads()
Handle uploads
public
static HandleMultipleUploads(Folder $folder, array<string|int, mixed> $payload[, bool $no_clear = false ]) : Result
Handle uploads of multiple assets and assignments to folder
Parameters
- $folder : Folder
-
The target folder
- $payload : array<string|int, mixed>
-
Configuration object files array List of fields with path, target template position and name data_type string The type of asset to create path string The target folder path
- $no_clear : bool = false
-
When set, do not delete the source folder afterwards
Return values
Result —A system result object
HasAccess()
Test if has access Test access permission on folder by specific user and level
public
static HasAccess(string $path, User|null $user[, string $op = 'view' ][, string|null $relation = null ]) : Result
Parameters
- $path : string
-
Virtual directory folder path
- $user : User|null
-
A system user object, is null for not logged users
- $op : string = 'view'
-
A registered system operation
- $relation : string|null = null
-
The relation id
Return values
Result —A default system result object
Is()
Test if path is valid virtual directory this function can't resolve bot opt links, they must be mapped before
public
static Is(string $path) : string|null
Parameters
- $path : string
-
Virtual directory folder path
Return values
string|null —Indicator whether this is a valid virtual or not
IsEmptyDir()
Is empty folder
public
static IsEmptyDir(string $dir) : bool|null
Parameters
- $dir : string
-
Path to folder
Return values
bool|null —KnownPlugins()
Get the known plugins
public
static KnownPlugins() : array<string|int, Plugin>
Return values
array<string|int, Plugin> —ListFiles()
list files Iterate over directory and list the found files
public
static ListFiles(string $dir[, string $ext = '/^json$/' ][, bool $full = false ]) : array<string|int, mixed>
Parameters
- $dir : string
-
The root folder path to search in
- $ext : string = '/^json$/'
-
Filter by extension (can be empty, a string or a regex)
- $full : bool = false
-
Check the full name of the file or just the extension when false
Return values
array<string|int, mixed> —A list containing the found files
ListFolders()
List folder names in certain root folder
public
static ListFolders(string $path) : array<string|int, mixed>
Parameters
- $path : string
-
The absolute path to the folder
Return values
array<string|int, mixed> —The found folder names that are children of the given folder
ListIdFiles()
Find file ids
public
static ListIdFiles(string $dir[, string $ext = 'json' ][, bool $to_int = true ]) : array<string|int, mixed>
Fetch a list of file ids inside a folder and its subdirectories
Parameters
- $dir : string
-
The root folder path to search in
- $ext : string = 'json'
-
Filter by extension
- $to_int : bool = true
-
Convert to integer when set to true
Return values
array<string|int, mixed> —A list containing the found id's
Log()
log object writs a formatted log message including back trace to the global log file
public
static Log(mixed $object[, string|null $msg = null ]) : bool
Parameters
- $object : mixed
-
The object to be logged
- $msg : string|null = null
-
Additional message
Return values
bool —MemoryBytesReadable()
Memory readable Convert size of bytes in human-readable units
public
static MemoryBytesReadable(int|float $size) : string
Parameters
- $size : int|float
-
The size in bytes
Return values
string —The calculated size
MkFolder()
Create folder path
public
static MkFolder(string $root, array<string|int, mixed> $components[, bool $make = true ]) : string|null
When the make argument set to true this function will try to create the folder Return the folder components without root part
Parameters
- $root : string
-
The path to the base folder
- $components : array<string|int, mixed>
-
The list of folder components
- $make : bool = true
-
Try to create the folder
Return values
string|null —The combined relative path as string, includes tailing /
MoveFoldersTo()
Move folders Move a set of folders to target that is not inside of one of the targets
public
static MoveFoldersTo(string $target, array<string|int, string> $folders) : Result
Parameters
- $target : string
-
Target virtual folder path
- $folders : array<string|int, string>
-
A list of folders
Return values
Result —A system result object
MoveRelation()
Function to move a relation by id to a new target folder
public
static MoveRelation(string $id, array<string|int, mixed> $data[, bool $no_check = false ]) : Result
Parameters
- $id : string
-
The relation id
- $data : array<string|int, mixed>
-
The relation update data
- $no_check : bool = false
-
Flag to skip checks
Return values
Result —OpenProject()
Open a project folder
public
static OpenProject( $dir[, null $language = null ]) : Project|null
Parameters
Return values
Project|null —OpenStorage()
Open a storage folder
public
static OpenStorage(string $dir[, string|null $language = null ]) : Storage|null
Parameters
- $dir : string
- $language : string|null = null
Return values
Storage|null —OpenTaskProject()
Open a task project
public
static OpenTaskProject( $dir[, null $language = null ]) : TaskProject|null
Parameters
Return values
TaskProject|null —OptimizedLinkToPath()
Resolve link Back resolve a optimized link
public
static OptimizedLinkToPath(string $link[, string $dom = '' ]) : Link|null
Parameters
- $link : string
-
The path to resolve
- $dom : string = ''
-
Additional domain filter
Return values
Link|null —The link object or null, when not registered
PathToOptimizedLink()
create optimized link get a optimized link based on the given language and the base folder.
public
static PathToOptimizedLink(string $language, string $folder[, string|Domain $domain = '__' ][, bool $no_default = false ]) : string
This method is locally cached
Parameters
- $language : string
-
A system language identifier
- $folder : string
-
A system folder identifier
- $domain : string|Domain = '__'
-
A system domain identifier or null
- $no_default : bool = false
-
When set, do not return the default link
Return values
string —A optimized link or the default link expression
Plugin()
Get plugin
public
static Plugin(string $name) : Plugin|null
Get one of the registered plugins. This function uses the cache
Parameters
- $name : string
-
Get plugin instance
Return values
Plugin|null —A plugin instance or null when not registered
PluginsActive()
public
static PluginsActive(bool $is) : void
Parameters
- $is : bool
Return values
void —ReadCsv()
Read a CSV file to local storage
public
static ReadCsv(string $path[, string $delimiter = ';' ][, string $enclosure = "'" ][, int $length = 100000 ][, string $escape = "\" ][, bool $check_head = true ]) : Result
Fetch the file and add it to a local result object file is parsed with php function to get csv from file, arguments of this method align with official one
Parameters
- $path : string
-
The absolute path to file to open
- $delimiter : string = ';'
-
Have a look at http://php.net/manual/de/function.fgetcsv.php delimiter
- $enclosure : string = "'"
-
Have a look at http://php.net/manual/de/function.fgetcsv.php enclosure
- $length : int = 100000
-
Have a look at http://php.net/manual/de/function.fgetcsv.php length
- $escape : string = "\"
-
Have a look at http://php.net/manual/de/function.fgetcsv.php escape
- $check_head : bool = true
-
When set, check the first line as head and validate following line lengths
Return values
Result —A system result object
ReadFile()
Read a single file
public
static ReadFile(string $path) : Result
Parameters
- $path : string
-
The absolute path to a certain storage file
Return values
Result —A default system result object
ReadFixedColumnFile()
Read file with fixed column width
public
static ReadFixedColumnFile(string $path[, int $length = 10000 ]) : Result
Automatic file parser based on the heads and assuming a " " space is used to make the cols equal
Parameters
- $path : string
-
Absolute link to the file to open
- $length : int = 10000
-
Limiter for line length
Return values
Result —A system result object
ReadFolder()
Read folder
public
static ReadFolder(string $dir) : array<string|int, File>
Will list all files and folders of a folder
Parameters
- $dir : string
-
Path to root folder
Return values
array<string|int, File> —An array of file objects
RegisterExistingContent()
Assign content to folder
public
static RegisterExistingContent(string $path, array<string|int, mixed> $payload, BaseContent $object[, bool $am = false ]) : Result
Parameters
- $path : string
-
Path to storage folder
- $payload : array<string|int, mixed>
-
The content relation
- $object : BaseContent
-
A system object
- $am : bool = false
Return values
Result —A default system result object
RegisterRelation()
Register a new relation Adds a new relation to a content into an existing virtual folder
public
static RegisterRelation(string $type, string $path, array<string|int, mixed> $payload[, array<string|int, mixed>|null $content_data = null ][, mixed $filter_types = null ][, bool $am = false ]) : Result
Parameters
- $type : string
-
The content type name, lowercase
- $path : string
-
The content relation virtual parent folder path (relative)
- $payload : array<string|int, mixed>
-
The content relation
- $content_data : array<string|int, mixed>|null = null
-
The content or null for empty content
- $filter_types : mixed = null
-
Alternative list of filter content types
- $am : bool = false
Return values
Result —A default system result object
RenameFolderOrFile()
Rename folder or file
public
static RenameFolderOrFile(string $source, string $target[, bool $skip_existing = true ]) : Result
Parameters
- $source : string
-
Absolute path to source
- $target : string
-
Absolute path to target
- $skip_existing : bool = true
Return values
Result —A system result object
Render503()
Handle the 503 response
public
static Render503(Request $request, Response $res) : void
Parameters
Return values
void —ResolveDomain()
Resolve hostname/FQDN to system domain
public
static ResolveDomain(string $host[, bool $ignore_state = false ]) : Domain|null
Parameters
- $host : string
-
The host name
- $ignore_state : bool = false
-
Ignore active state on demand
Return values
Domain|null —RevokeLock()
release lock try to release the lock indicated by lock file in var
public
static RevokeLock([string|null $lockfile = null ][, bool $in_memory = true ]) : Result
Parameters
- $lockfile : string|null = null
- $in_memory : bool = true
Return values
Result —A default system result object
RevokeObjectLock()
Revoke dedicated object lock
public
static RevokeObjectLock(BaseContent $content) : Result
Parameters
- $content : BaseContent
Tags
Return values
Result —SaveDomainConfig()
Store the domain configuration
public
static SaveDomainConfig(array<string|int, mixed> $data) : Result
Parameters
- $data : array<string|int, mixed>
-
A list of configuration options
Return values
Result —A default system result object
SelfLockedOrOpen()
public
static SelfLockedOrOpen( $pid[, $path = null ]) : bool
Parameters
Return values
bool —ServeRequest()
serve request parse the given request and send fitting http response
public
static ServeRequest(string $path, Request $request, Response $response) : Response
Parameters
- $path : string
-
Virtual directory folder path
- $request : Request
-
A system request object
- $response : Response
Return values
Response —ServiceDeepLink()
Build deep link to a certain service
public
static ServiceDeepLink(Relation $relation[, string|null $l = null ]) : string|null
Parameters
- $relation : Relation
-
The relation to link to
- $l : string|null = null
-
The target language
Return values
string|null —The deep link or, null when not found
StoreEncodedJson()
Serialize a given input and store it
public
static StoreEncodedJson(string $path, mixed $data[, int $mode = JSON_PRETTY_PRINT ][, bool|null $crypt = false ]) : Result
use the json parse function to create json representation and store it in a certain file this method does an encryption also on demand, the .key file must exist for this to happen
Parameters
- $path : string
-
The target file path
- $data : mixed
-
The payload to encode
- $mode : int = JSON_PRETTY_PRINT
-
Serialize readable or not formatted
- $crypt : bool|null = false
-
Encrypt the result after serialisation
Return values
Result —A default system result object
StripQueryAndAnchor()
Extract file name
public
static StripQueryAndAnchor(string $path) : string
Parameters
- $path : string
-
A complete file path
Return values
string —The file name without additional parts
SysLog()
Log message
public
static SysLog(string $level, mixed $object[, string|null $prefix = null ][, bool $stack = true ]) : bool
Writs a formatted log message including back trace on severe levels to the global log file
Parameters
- $level : string
-
Name of the log level
- $object : mixed
-
The object to be logged
- $prefix : string|null = null
-
Extra prefix
- $stack : bool = true
-
Print with stack trace on demand
Return values
bool —Status if write to log worked
TaskProjectDeepLink()
Create a task board deep link
public
static TaskProjectDeepLink(Task|null $task[, string|null $l = null ][, bool $filter = true ]) : string|null
Parameters
- $task : Task|null
- $l : string|null = null
- $filter : bool = true
Return values
string|null —TryGetLock()
Obtain lock with retry
public
static TryGetLock([string|null $path = null ][, string|int|null $pid = null ][, int $try_count = FAA_WRITE_RETRY ][, float $seconds = 0.25 ][, bool $in_memory = true ]) : bool
Try to obtain the lock indicated by lock file in var Additional lock level reliability with process id
Parameters
- $path : string|null = null
-
The lock file path or null for default
- $pid : string|int|null = null
-
The current process id locking the file
- $try_count : int = FAA_WRITE_RETRY
-
Retry counter
- $seconds : float = 0.25
-
Retry wait
- $in_memory : bool = true
-
Instead of file system use redis as lock file storage
Tags
Return values
bool —UpdateRelation()
Change relation Update a content relation and when defined, also the assigned content.
public
static UpdateRelation(string $id, string $path, array<string|int, mixed> $payload[, array<string|int, mixed>|null $content_data = null ][, bool $stage = true ]) : Result
Parameters
- $id : string
-
A relation primary id
- $path : string
-
Relative parent folder path
- $payload : array<string|int, mixed>
-
The relation definition
- $content_data : array<string|int, mixed>|null = null
-
The content data for direct content assignment
- $stage : bool = true
Return values
Result —A system result object
Version()
public
static Version() : string
Return values
string —VersionStringToNumber()
Convert version number Converts the given number to a unified string e.g. 'v1.234.33' will become 102340033
public
static VersionStringToNumber(string $number[, string $regex = '/[^0-9\.]/i' ][, string $replace = '' ][, int $pads = 4 ]) : string
Parameters
- $number : string
-
The version number to calculate
- $regex : string = '/[^0-9\.]/i'
-
Replacement expression to clear the number upfront
- $replace : string = ''
-
Replacement string for regex_replace
- $pads : int = 4
-
Add this amount of zeros to the left
Return values
string —The cleared version number
Warn()
warn level log object writs a formatted log message including back trace to the global log file
public
static Warn(mixed $object[, bool $stack = true ]) : bool
Parameters
- $object : mixed
-
The object to be logged
- $stack : bool = true
Return values
bool —WriteCsv()
Write an array of entries to csv file
public
static WriteCsv(string|null $path, array<string|int, mixed> $list[, string $delimiter = ';' ][, string $enclosure = "'" ][, string $escape = "\" ]) : Result
Parameters
- $path : string|null
-
The absolute path to file to open
- $list : array<string|int, mixed>
-
The source to write
- $delimiter : string = ';'
-
Have a look at http://php.net/manual/de/function.fgetcsv.php delimiter
- $enclosure : string = "'"
-
Have a look at http://php.net/manual/de/function.fgetcsv.php enclosure
- $escape : string = "\"
-
Have a look at http://php.net/manual/de/function.fgetcsv.php escape
Return values
Result —The result
WriteFile()
Write string to file
public
static WriteFile(string $path, scalar $data, int $flags) : bool
This method writes the given data to the defined file, it will wait when the system is in git lock mode. This method returns valid result also for writing empty strings unlike file put contents default behavior
Parameters
- $path : string
-
The target file path
- $data : scalar
-
The payload to store in the target file
- $flags : int
-
File put content flags (http://php.net/manual/de/function.file-put-contents.php)
Return values
bool —True on success
RegisterPlugins()
Register plugins
protected
static RegisterPlugins() : void
Load the plugins from filesystem and register them for hook calling This function is cached.
Return values
void —CalculateFolderSizeRecurse()
Helper function to calculate size Recursively calculate size of a specific folder
private
static CalculateFolderSizeRecurse(string $folder, int &$file_count, int &$directory_count, int &$size) : bool
Parameters
- $folder : string
-
The path to calculate the size of
- $file_count : int
-
Pointer to file count
- $directory_count : int
-
Pointer to folder count
- $size : int
-
Pointer to file size
Return values
bool —The iteration result status
copyFoldersRecursive()
Helper to recursively copy a folder
private
static copyFoldersRecursive(string $target, string $source) : Result|null
Parameters
- $target : string
- $source : string
Return values
Result|null —decrypt()
Decrypt data
private
static decrypt(string $encrypted[, string|array<string|int, mixed> $mc_key = FAA_CODE ]) : string
will try to decrypt the given data with the system encryption code or a customer defined one The function does a blowfish decryption and a base64 conversion on demand
Parameters
- $encrypted : string
-
The string to decrypt (must be base64 encoded)
- $mc_key : string|array<string|int, mixed> = FAA_CODE
-
The key or, an array with cipher, key and the iv
Tags
Return values
string —The decrypted string
DropFolderRecurse()
Delete a folder completely this method is the recursion helper for DropFolder()
private
static DropFolderRecurse(string $folder[, bool $full = false ]) : bool
Parameters
- $folder : string
-
The path to delete
- $full : bool = false
-
Also remove the root folder
Return values
bool —The delete status
encrypt()
Encrypt data
private
static encrypt(string $plain[, string|array<string|int, mixed> $mc_key = FAA_CODE ][, mixed &$tag = null ]) : string
Method will try to encrypt the given data with the system encryption code or a customer defined one The function does a blowfish encryption and a base64 conversion
Parameters
- $plain : string
-
The string to encrypt
- $mc_key : string|array<string|int, mixed> = FAA_CODE
-
The key or, an array with cipher, key and the iv
- $tag : mixed = null
Tags
Return values
string —The encrypted string base64 encoded
execCopyMoveRelation()
Move or, copy a relation with content
private
static execCopyMoveRelation(string $mode, string $id, array<string|int, mixed> $data[, bool $no_check = false ]) : Result
Support moving/copy of single extension or, relation to new or same parent folder. Can change the order and the position during this process.
By default, it will check if the current user has the permission in the corresponding folders, for move a source edit and a target add is needed, for copy a read and add are required
Parameters
- $mode : string
-
Either cove or, copy
- $id : string
-
The id of the source relation
- $data : array<string|int, mixed>
-
The new data with target folder and settings like order, position string [folder] The target folder, relative to folder/ string [position] The new position int [order] The new sort order
- $no_check : bool = false
Return values
Result —A system result object
filterFetchRelations()
Find a set of relations in a certain folder defined by filter set
private
static filterFetchRelations(FolderTree $folder, array<string|int, Filter> $filters, array<string|int, mixed> $sort, string $language, bool $plain) : array<string|int, mixed>
Parameters
- $folder : FolderTree
-
The folder tree object
- $filters : array<string|int, Filter>
-
A list of filters
- $sort : array<string|int, mixed>
-
A set of sort arguments
- $language : string
-
The language key
- $plain : bool
-
When set to true, convert the relation to raw object
Return values
array<string|int, mixed> —A list of found relations either plain or as object
moveFoldersRecursive()
Move the source folder to target
private
static moveFoldersRecursive(string $target, string $source) : Result
Parameters
- $target : string
-
The target directory path
- $source : string
-
The source directory path
Return values
Result —A system result
parseKeyFile()
private
static parseKeyFile(string $path) : string|array<string|int, mixed>|null
Parameters
- $path : string
Return values
string|array<string|int, mixed>|null —postProcessDisplay()
Post process
private
static postProcessDisplay(Request $request, object|null $hook, string &$html, FolderTree $folder) : void
Apply post process method to given element like short code parser image and link resolver
Parameters
- $request : Request
-
A request object
- $hook : object|null
-
A hook object
- $html : string
-
The preprocessed html
- $folder : FolderTree
-
Uses maximum cache level
Return values
void —resolveErrorTemplate()
Fetch the corresponding error template by code
private
static resolveErrorTemplate(Request $request[, int $code = 404 ]) : Result
Parameters
- $request : Request
-
The served request
- $code : int = 404
-
The error code to search for