model/modx/modx.class.php

Includes Constants Classes 
package
modx
Constants
MODX_CORE_PATH
MODX_CONFIG_KEY
Classes
modX
modSystemEvent

Description

This is the main file to include in your scripts to use MODX.

For detailed information on using this class, see {@tutorial modx/modx.pkg}.

Constants

MODX_CORE_PATH

 MODX_CORE_PATH = 'dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR'

Details

value
dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR

MODX_CONFIG_KEY

 MODX_CONFIG_KEY = ''config''

Details

value
'config'

\modSystemEvent

package
modx
Constants
MODE_NEW
MODE_UPD
Properties
$_output
$_propagate
$activated
$activePlugin
$name
$params
$propertySet
$returnedValues
Methods
alert
isPropagatable
output
resetEventObject
stopPropagation

Description

Represents a modEvent when invoking events.

Constants

MODE_NEW

\const MODE_NEW = 'new'

Details

value
new
\const
For new creations of objects in model events

MODE_UPD

\const MODE_UPD = 'upd'

Details

value
upd
\const
For updating objects in model events

Properties

$_output

 $_output = ''

Details

visibility
public
default
final
false
static
false

$_propagate

boolean $_propagate = 'true'

Details

boolean
visibility
protected
default
true
final
false
static
false

$activated

boolean $activated = ''

Details

boolean
visibility
public
default
final
false
static
false

$activePlugin

 $activePlugin = ''

Details

visibility
public
default
final
false
static
false

$name

 $name = ''

Details

visibility
public
default
final
false
static
false

$params

array $params = ''

Details

array
visibility
public
default
final
false
static
false

$propertySet

 $propertySet = ''

Details

visibility
public
default
final
false
static
false

$returnedValues

mixed $returnedValues = ''

Details

mixed
visibility
public
default
final
false
static
false

Methods

alert

alert( string $msg ) :

Display a message to the user during the event.

Arguments
$msg
string
The message to display.
Details
visibility
public
final
false
static
false
todo
Remove this; the centralized modRegistry will handle configurable logging of any kind of message or data to any repository or output context. Use {@link modX::_log()} in the meantime.

isPropagatable

isPropagatable( ) : boolean

Returns whether the event will propagate or not.

Output
boolean
Details
visibility
public
final
false
static
false
access
public

output

output( string $output ) :

Render output from the event.

Arguments
$output
string
The output to render.
Details
visibility
public
final
false
static
false

resetEventObject

resetEventObject( ) :

Reset the event instance for reuse.

Details
visibility
public
final
false
static
false

stopPropagation

stopPropagation( ) :

Stop further execution of plugins for this event.

Details
visibility
public
final
false
static
false

\modX

Extends from
\xPDO
package
modx
Constants
LOG_LEVEL_DEBUG
LOG_LEVEL_ERROR
LOG_LEVEL_FATAL
LOG_LEVEL_INFO
LOG_LEVEL_WARN
SESSION_STATE_EXTERNAL
SESSION_STATE_INITIALIZED
SESSION_STATE_UNAVAILABLE
SESSION_STATE_UNINITIALIZED
Properties
$Event
$_config
$_initialized
$_logSequence
$_sessionState
$_systemConfig
$_userConfig
$actionMap
$aliasMap
$contentTypes
$context
$contexts
$cultureKey
$documentOutput
$elementCache
$errorHandler
$event
$eventMap
$jscripts
$lexicon
$loadedjscripts
$parser
$placeholders
$pluginCache
$request
$resource
$resourceGenerated
$resourceIdentifier
$resourceListing
$resourceMap
$resourceMethod
$response
$sanitizePatterns
$services
$sjscripts
$sourceCache
$stopOnNotice
$user
$version
$virtualDir
Methods
__construct
_initContext
_initCulture
_initErrorHandler
_initEventMap
_initSession
_loadConfig
_loadExtensionPackages
_log
_logInRegister
_postProcess
addEventListener
beforeProcessing
beforeRender
beforeRequest
checkForLocks
checkSession
checkSiteStatus
getAuthenticatedUser
getCacheManager
getChildIds
getChunk
getConfig
getContext
getEventMap
getLoginUserID
getLoginUserName
getParentIds
getParser
getPlaceholder
getRegisteredClientScripts
getRegisteredClientStartupScripts
getRequest
getResponse
getSessionState
getTree
getUser
getVersionData
handleRequest
hasPermission
initialize
invokeEvent
isInitialized
lexicon
logManagerAction
makeUrl
messageQuit
parseChunk
protect
regClientCSS
regClientHTMLBlock
regClientScript
regClientStartupHTMLBlock
regClientStartupScript
reloadConfig
removeAllEventListener
removeEventListener
runProcessor
runSnippet
sanitize
sanitizeString
sendError
sendErrorPage
sendForward
sendRedirect
sendUnauthorizedPage
setDebug
setPlaceholder
setPlaceholders
stripTags
switchContext
toPlaceholder
toPlaceholders
toQueryString
unsetPlaceholder
unsetPlaceholders

Description

This is the MODX gateway class.

It can be used to interact with the MODX framework and serves as a front controller for handling requests to the virtual resources managed by the MODX Content Management Framework.

Constants

LOG_LEVEL_FATAL

 LOG_LEVEL_FATAL = '0'

Details

value
0

LOG_LEVEL_ERROR

 LOG_LEVEL_ERROR = '1'

Details

value
1

LOG_LEVEL_WARN

 LOG_LEVEL_WARN = '2'

Details

value
2

LOG_LEVEL_INFO

 LOG_LEVEL_INFO = '3'

Details

value
3

LOG_LEVEL_DEBUG

 LOG_LEVEL_DEBUG = '4'

Details

value
4

SESSION_STATE_UNAVAILABLE

 SESSION_STATE_UNAVAILABLE = ''

Details

value

SESSION_STATE_UNINITIALIZED

 SESSION_STATE_UNINITIALIZED = '0'

Details

value
0

SESSION_STATE_INITIALIZED

 SESSION_STATE_INITIALIZED = '1'

Details

value
1

SESSION_STATE_EXTERNAL

 SESSION_STATE_EXTERNAL = '2'

Details

value
2

Properties

$Event

 $Event = 'null'

Details

visibility
public
default
null
final
false
static
false

$_configA config array that stores the bootstrap settings.

array $_config = 'null'

Details

array
A config array that stores the bootstrap settings.
visibility
protected
default
null
final
false
static
false

$_initializedIndicates if modX has been successfully initialized for a modContext.

boolean $_initialized = 'false'

Details

boolean
Indicates if modX has been successfully initialized for a modContext.
visibility
protected
default
false
final
false
static
false

$_logSequence

 $_logSequence = '0'

Details

visibility
protected
default
0
final
false
static
false

$_sessionStateAn integer representing the session state of modX.

integer $_sessionState = 'modX'

Details

integer
An integer representing the session state of modX.
visibility
protected
default
modX
final
false
static
false

$_systemConfigA config array that stores the system-wide settings.

array $_systemConfig = 'null'

Details

array
A config array that stores the system-wide settings.
visibility
public
default
null
final
false
static
false

$_userConfigA config array that stores the user settings.

array $_userConfig = 'array'

Details

array
A config array that stores the user settings.
visibility
public
default
array
final
false
static
false

$actionMapA map of actions registered to the manager interface.

array $actionMap = 'null'

Details

array
A map of actions registered to the manager interface.
visibility
public
default
null
final
false
static
false

$aliasMapA lookup listing of Resource alias values and associated Resource Ids

array $aliasMap = 'null'

Details

array
A lookup listing of Resource alias values and associated Resource Ids
visibility
public
default
null
final
false
static
false

$contentTypesRepresents the modContentType instances that can be delivered by this modX deployment.

array $contentTypes = 'null'

Details

array
Represents the modContentType instances that can be delivered by this modX deployment.
visibility
public
default
null
final
false
static
false

$contextThe Context represents a unique section of the site which this modX instance is controlling.

\modContext $context = 'null'

Details

\modContext
The Context represents a unique section of the site which this modX instance is controlling.
visibility
public
default
null
final
false
static
false

$contextsAn array of secondary contexts loaded on demand.

array $contexts = 'array'

Details

array
An array of secondary contexts loaded on demand.
visibility
public
default
array
final
false
static
false

$cultureKeyThe preferred Culture key for the current request.

string $cultureKey = ''

Details

string
The preferred Culture key for the current request.
visibility
public
default
final
false
static
false

$documentOutput

 $documentOutput = 'null'

Details

visibility
public
default
null
final
false
static
false

$elementCacheA map of already processed Elements.

array $elementCache = 'array'

Details

array
A map of already processed Elements.
visibility
public
default
array
final
false
static
false

$errorHandlerAn error_handler for the modX instance.

object $errorHandler = 'null'

Details

object
An error_handler for the modX instance.
visibility
public
default
null
final
false
static
false

$eventThe current event being handled by modX.

\modSystemEvent $event = 'null'

Details

\modSystemEvent
The current event being handled by modX.
visibility
public
default
null
final
false
static
false

$eventMapA map of elements registered to specific events.

array $eventMap = 'null'

Details

array
A map of elements registered to specific events.
visibility
public
default
null
final
false
static
false

$jscriptsAn array of javascript content to be inserted into the BODY of an HTML resource.

array $jscripts = 'array'

Details

array
An array of javascript content to be inserted into the BODY of an HTML resource.
visibility
public
default
array
final
false
static
false

$lexiconRepresents a localized dictionary of common words and phrases.

\modLexicon $lexicon = 'null'

Details

\modLexicon
Represents a localized dictionary of common words and phrases.
visibility
public
default
null
final
false
static
false

$loadedjscripts

 $loadedjscripts = 'array'

Details

visibility
public
default
array
final
false
static
false

$parserThe modParser registered for this modX instance, responsible for content tag parsing, and loaded only on demand.

\modParser $parser = 'null'

Details

\modParser
The modParser registered for this modX instance, responsible for content tag parsing, and loaded only on demand.
visibility
public
default
null
final
false
static
false

$placeholdersAn array of key=> value pairs that can be used by any Resource or Element.

array $placeholders = 'array'

Details

array
An array of key=> value pairs that can be used by any Resource or Element.
visibility
public
default
array
final
false
static
false

$pluginCache

 $pluginCache = 'array'

Details

visibility
public
default
array
final
false
static
false

$requestRepresents a web request and provides helper methods for dealing with request parameters and other attributes of a request.

\modRequest $request = 'null'

Details

\modRequest
Represents a web request and provides helper methods for dealing with request parameters and other attributes of a request.
visibility
public
default
null
final
false
static
false

$resourceAn instance of the current modResource controlling the request.

\modResource $resource = 'null'

Details

\modResource
An instance of the current modResource controlling the request.
visibility
public
default
null
final
false
static
false

$resourceGeneratedIndicates if the resource was generated during this request.

boolean $resourceGenerated = 'false'

Details

boolean
Indicates if the resource was generated during this request.
visibility
public
default
false
final
false
static
false

$resourceIdentifierThe resource id or alias being requested.

mixed $resourceIdentifier = 'null'

Details

mixed
The resource id or alias being requested.
visibility
public
default
null
final
false
static
false

$resourceListingA listing of site Resources and Context-specific meta data.

array $resourceListing = 'null'

Details

array
A listing of site Resources and Context-specific meta data.
visibility
public
default
null
final
false
static
false

$resourceMapA hierarchy map of Resources.

array $resourceMap = 'null'

Details

array
A hierarchy map of Resources.
visibility
public
default
null
final
false
static
false

$resourceMethodThe method to use to locate the Resource, 'id' or 'alias'.

string $resourceMethod = 'null'

Details

string
The method to use to locate the Resource, 'id' or 'alias'.
visibility
public
default
null
final
false
static
false

$responseRepresents a web response, providing helper methods for managing response header attributes and the body containing the content of the response.

\modResponse $response = 'null'

Details

\modResponse
Represents a web response, providing helper methods for managing response header attributes and the body containing the content of the response.
visibility
public
default
null
final
false
static
false

$sanitizePatternsAn array of regex patterns regulary cleansed from content.

array $sanitizePatterns = 'array'

Details

array
An array of regex patterns regulary cleansed from content.
visibility
public
default
array
final
false
static
false

$servicesAn array of supplemental service classes for this modX instance.

array $services = 'array'

Details

array
An array of supplemental service classes for this modX instance.
visibility
public
default
array
final
false
static
false

$sjscriptsAn array of javascript content to be inserted into the HEAD of an HTML resource.

array $sjscripts = 'array'

Details

array
An array of javascript content to be inserted into the HEAD of an HTML resource.
visibility
public
default
array
final
false
static
false

$sourceCache

 $sourceCache = 'array'

Details

visibility
public
default
array
final
false
static
false

$stopOnNotice

 $stopOnNotice = 'false'

Details

visibility
public
default
false
final
false
static
false

$userThe current user object, if one is authenticated for the current request and context.

\modUser $user = 'null'

Details

\modUser
The current user object, if one is authenticated for the current request and context.
visibility
public
default
null
final
false
static
false

$versionVersion information for this MODX deployment.

array $version = 'null'

Details

array
Version information for this MODX deployment.
visibility
public
default
null
final
false
static
false

$virtualDirStores the virtual path for a request to MODX if the friendly_alias_paths option is enabled.

string $virtualDir = ''

Details

string
Stores the virtual path for a request to MODX if the friendly_alias_paths option is enabled.
visibility
public
default
final
false
static
false

Methods

__construct

__construct( string $configPath, array $options = array ) : \modX

Construct a new modX instance.

This method is used to create a new xPDO object with a connection to a specific database container.

Arguments
$configPath
string
An absolute filesystem path to look for the config file.
$options
array
Options that can be passed to the instance.
Output
\modX
A new modX instance.
Details
visibility
public
final
false
static
false

_initContext

_initContext( string $contextKey ) :

Loads a specified Context.

Merges any context settings with the modX::$config, and performs any other context specific initialization tasks.

Arguments
$contextKey
string
A context identifier.
Details
visibility
protected
final
false
static
false
access
protected

_initCulture

_initCulture( ) :

Initializes the culture settings.

Details
visibility
protected
final
false
static
false
access
protected

_initErrorHandler

_initErrorHandler( ) :

Loads the error handler for this instance.

Details
visibility
protected
final
false
static
false
access
protected

_initEventMap

_initEventMap( string $contextKey ) :

Populates the map of events and registered plugins for each.

Arguments
$contextKey
string
Context identifier.
Details
visibility
protected
final
false
static
false
access
protected

_initSession

_initSession( ) :

Loads the session handler and starts the session.

Details
visibility
protected
final
false
static
false
access
protected

_loadConfig

_loadConfig( ) : boolean

Loads the modX system configuration settings.

Output
boolean
True if successful.
Details
visibility
protected
final
false
static
false
access
protected

_loadExtensionPackages

_loadExtensionPackages( ) :

Loads any specified extension packages

Details
visibility
protected
final
false
static
false

_log

_log( integer $level, string $msg, string $target, string $def, string $file, string $line ) :

Provides modX the ability to use modRegister instances as log targets.

{@inheritdoc}

Arguments
$level
integer
The level of the logged message.
$msg
string
The message to log.
$target
string
The logging target.
$def
string
The name of a defining structure (such as a class) to help identify the log event source.
$file
string
A filename in which the log event occured.
$line
string
A line number to help locate the source of the event within the indicated file.
Details
visibility
protected
final
false
static
false

_logInRegister

_logInRegister(  $register,  $level,  $msg,  $def,  $file,  $line ) :

Provides custom logging functionality for modRegister targets.

Arguments
$register
$level
$msg
$def
$file
$line
Details
visibility
protected
final
false
static
false
access
protected

_postProcess

_postProcess( ) :

Executed after the response is sent and execution is completed.

Details
visibility
public
final
false
static
false
access
protected

addEventListener

addEventListener( string $event, integer $pluginId ) : boolean

Add a plugin to the eventMap within the current execution cycle.

Arguments
$event
string
Name of the event.
$pluginId
integer
Plugin identifier to add to the event.
Output
boolean
true if the event is successfully added, otherwise false.
Details
visibility
public
final
false
static
false

beforeProcessing

beforeProcessing( ) :

Executed before parser processing of an element.

Details
visibility
public
final
false
static
false

beforeRender

beforeRender( ) :

Executed before the response is rendered.

Details
visibility
public
final
false
static
false

beforeRequest

beforeRequest( ) :

Executed before the handleRequest function.

Details
visibility
public
final
false
static
false

checkForLocks

checkForLocks( integer $id, string $action, string $type ) :

Checks for locking on a page.

Arguments
$id
integer
Id of the user checking for a lock.
$action
string
The action identifying what is locked.
$type
string
Message indicating the kind of lock being checked.
Details
visibility
public
final
false
static
false

checkSession

checkSession( string $sessionContext = web ) : boolean

Checks to see if the user has a session in the specified context.

Arguments
$sessionContext
string
The context to test for a session key in.
Output
boolean
True if the user is valid in the context specified.
Details
visibility
public
final
false
static
false

checkSiteStatus

checkSiteStatus( ) : boolean

Determines the current site_status.

Output
boolean
True if the site is online or the user has a valid user session in the 'mgr' context; false otherwise.
Details
visibility
public
final
false
static
false

getAuthenticatedUser

getAuthenticatedUser( string $contextKey ) : \modUser|null

Gets the user authenticated in the specified context.

Arguments
$contextKey
string
Optional context key; uses current context by default.
Output
\modUser|null
The user object that is authenticated in the specified context, or null if no user is authenticated.
Details
visibility
public
final
false
static
false

getCacheManager

getCacheManager( string $class = cache.xPDOCacheManager,  $options = array ) : object

Get an extended xPDOCacheManager instance responsible for MODX caching.

This class is responsible for handling all types of caching operations for the xPDO core.

Arguments
$class
string
Optional name of a derivative xPDOCacheManager class.
$options
Output
object
A modCacheManager registered for this modX instance.
Details
visibility
public
final
false
static
false

getChildIds

getChildIds( integer $id = null, integer $depth = 10, array $options = array ) : array

Gets all of the child resource ids for a given resource.

Arguments
$id
integer
The resource id for the starting node.
$depth
integer
How many levels max to search for children (default 10).
$options
array
An array of filtering options, such as 'context' to specify the context to grab from
Output
array
An array of all the child resource ids for the specified resource.
Details
visibility
public
final
false
static
false
see
getTree for hierarchical node results

getChunk

getChunk( string $chunkName, array $properties = array ) : string

Process and return the output from a Chunk by name.

Arguments
$chunkName
string
The name of the chunk.
$properties
array
An associative array of properties to process the Chunk with, treated as placeholders within the scope of the Element.
Output
string
The processed output of the Chunk.
Details
visibility
public
final
false
static
false

getConfig

getConfig( ) : array

Get the configuration for the site.

Output
array
An associate array of configuration key/values
Details
visibility
public
final
false
static
false

getContext

getContext( string $contextKey ) : \modContext

Retrieve a context by name without initializing it.

Within a request, contexts retrieved using this function will cache the context data into the modX::$contexts array to avoid loading the same context multiple times.

Arguments
$contextKey
string
The context to retrieve.
Output
\modContext
A modContext object retrieved from cache or database.
Details
visibility
public
final
false
static
false
access
public

getEventMap

getEventMap( string $contextKey ) : array

Gets a map of events and registered plugins for the specified context.

Service #s: 1 - Parser Service Events 2 - Manager Access Events 3 - Web Access Service Events 4 - Cache Service Events 5 - Template Service Events 6 - User Defined Events

Arguments
$contextKey
string
Context identifier.
Output
array
A map of events and registered plugins for each.
Details
visibility
public
final
false
static
false

getLoginUserID

getLoginUserID( string $context ) : integer

Returns the current user ID, for the current or specified context.

Arguments
$context
string
The key of a valid modContext so you can retrieve the current user ID from a different context than the current.
Output
integer
The ID of the current user.
Details
visibility
public
final
false
static
false

getLoginUserName

getLoginUserName( string $context ) : string

Returns the current user name, for the current or specified context.

Arguments
$context
string
The key of a valid modContext so you can retrieve the username from a different context than the current.
Output
string
The username of the current user.
Details
visibility
public
final
false
static
false

getParentIds

getParentIds( integer $id = null, integer $height = 10, array $options = array ) : array

Gets all of the parent resource ids for a given resource.

Arguments
$id
integer
The resource id for the starting node.
$height
integer
How many levels max to search for parents (default 10).
$options
array
An array of filtering options, such as 'context' to specify the context to grab from
Output
array
An array of all the parent resource ids for the specified resource.
Details
visibility
public
final
false
static
false

getParser

getParser( ) : object

Gets the MODX parser.

Returns an instance of modParser responsible for parsing tags in element content, performing actions, returning content and/or sending other responses in the process.

Output
object
The modParser for this modX instance.
Details
visibility
public
final
false
static
false

getPlaceholder

getPlaceholder( string $key ) : mixed

Get a placeholder value by key.

Arguments
$key
string
The key of the placeholder to a return a value from.
Output
mixed
The value of the requested placeholder, or an empty string if not located.
Details
visibility
public
final
false
static
false

getRegisteredClientScripts

getRegisteredClientScripts( ) : string

Returns all registered JavaScripts.

Output
string
The parsed HTML of the client scripts.
Details
visibility
public
final
false
static
false
access
public

getRegisteredClientStartupScripts

getRegisteredClientStartupScripts( ) : string

Returns all registered startup CSS, JavaScript, or HTML blocks.

Output
string
The parsed HTML of the startup scripts.
Details
visibility
public
final
false
static
false
access
public

getRequest

getRequest( \$string $class = modRequest, \$path $path ) : boolean

Attempt to load the request handler class, if not already loaded.

Arguments
$class
\$string
The class name of the response class to load. Defaults to modRequest; is ignored if the Setting "modRequest.class" is set.
$path
\$path
The absolute path by which to load the response class from. Defaults to the current MODX model path.
Output
boolean
Returns true if a valid request handler object was loaded on this or any previous call to the function, false otherwise.
Details
visibility
public
final
false
static
false
access
public

getResponse

getResponse( \$string $class = modResponse, \$path $path ) : boolean

Attempt to load the response handler class, if not already loaded.

Arguments
$class
\$string
The class name of the response class to load. Defaults to modResponse; is ignored if the Setting "modResponse.class" is set.
$path
\$path
The absolute path by which to load the response class from. Defaults to the current MODX model path.
Output
boolean
Returns true if a valid response handler object was loaded on this or any previous call to the function, false otherwise.
Details
visibility
public
final
false
static
false
access
public

getSessionState

getSessionState( ) : integer

Returns the state of the SESSION being used by modX.

The possible values for session state are:

modX::SESSION_STATE_UNINITIALIZED modX::SESSION_STATE_UNAVAILABLE modX::SESSION_STATE_EXTERNAL modX::SESSION_STATE_INITIALIZED

Output
integer
Returns an integer representing the session state.
Details
visibility
public
final
false
static
false

getTree

getTree( int|array $id = null, int $depth = 10 ) : array

Get a site tree from a single or multiple modResource instances.

Arguments
$id
intarray
A single or multiple modResource ids to build the tree from.
$depth
int
The maximum depth to build the tree (default 10).
Output
array
An array containing the tree structure.
Details
visibility
public
final
false
static
false
see
getChildIds for linear results

getUser

getUser( string $contextKey, boolean $forceLoadSettings = false ) : \modUser

Get the current authenticated User and assigns it to the modX instance.

Arguments
$contextKey
string
An optional context to get the user from.
$forceLoadSettings
boolean
If set to true, will load settings regardless of whether the user has an authenticated context or not.
Output
\modUser
The user object authenticated for the request.
Details
visibility
public
final
false
static
false

getVersionData

getVersionData( ) : array

Gets the modX core version data.

Output
array
The version data loaded from the config version file.
Details
visibility
public
final
false
static
false

handleRequest

handleRequest( ) : mixed

Initialize, cleanse, and process a request made to a modX site.

Output
mixed
The result of the request handler.
Details
visibility
public
final
false
static
false

hasPermission

hasPermission( string $pm ) : boolean

Returns true if user has the specified policy permission.

Arguments
$pm
string
Permission key to check.
Output
boolean
Details
visibility
public
final
false
static
false

initialize

initialize( string $contextKey = web ) : void

Initializes the modX engine.

This includes preparing the session, pre-loading some common classes and objects, the current site and context settings, extension packages used to override session handling, error handling, or other initialization classes

Arguments
$contextKey
string
Indicates the context to initialize.
Details
visibility
public
final
false
static
false

invokeEvent

invokeEvent( string $eventName, array $params = array ) :

Invokes a specified Event with an optional array of parameters.

Arguments
$eventName
string
Name of an event to invoke.
$params
array
Optional params provided to the elements registered with an event.
Details
visibility
public
final
false
static
false
access
public
todo
refactor this completely, yuck!!

isInitialized

isInitialized( ) : boolean

Returns whether modX instance has been initialized or not.

Output
boolean
Details
visibility
public
final
false
static
false
access
public

lexicon

lexicon( string $key, array $params = array ) :

Grabs a processed lexicon string.

Arguments
$key
string
$params
array
Details
visibility
public
final
false
static
false
access
public

logManagerAction

logManagerAction( string $action, string $class_key, mixed $item ) : \modManagerLog

Logs a manager action.

Arguments
$action
string
The action to pull from the lexicon module.
$class_key
string
The class key that the action is being performed on.
$item
mixed
The primary key id or array of keys to grab the object with
Output
\modManagerLog
The newly created modManagerLog object
Details
visibility
public
final
false
static
false
access
public

makeUrl

makeUrl( integer $id, string $context, string $args, mixed $scheme = 1 ) : string

Generates a URL representing a specified resource.

Arguments
$id
integer
The id of a resource.
$context
string
Specifies a context to limit URL generation to.
$args
string
A query string to append to the generated URL.
$scheme
mixed
The scheme indicates in what format the URL is generated.<br> <pre> -1 : (default value) URL is relative to site_url 0 : see http 1 : see https full : URL is absolute, prepended with site_url from config abs : URL is absolute, prepended with base_url from config http : URL is absolute, forced to http scheme https : URL is absolute, forced to https scheme </pre>
Output
string
The URL for the resource.
Details
visibility
public
final
false
static
false

messageQuit

messageQuit(  $msg = unspecified error,  $query,  $is_error = true,  $nr,  $file,  $source,  $text,  $line ) :

Legacy fatal error message.

Arguments
$msg
$query
$is_error
$nr
$file
$source
$text
$line
Details
visibility
public
final
false
static
false

parseChunk

parseChunk( string $chunkName, array $chunkArr, string $prefix = [[+, string $suffix = ]] ) : string

Parse a chunk using an associative array of replacement variables.

Arguments
$chunkName
string
The name of the chunk.
$chunkArr
array
An array of properties to replace in the chunk.
$prefix
string
The placeholder prefix, defaults to [[+.
$suffix
string
The placeholder suffix, defaults to ]].
Output
string
The processed chunk with the placeholders replaced.
Details
visibility
public
final
false
static
false

protect

protect( ) :

Harden the environment against common security flaws.

Details
visibility
public
final
false
static
true
static

regClientCSS

regClientCSS( string $src ) :

Register CSS to be injected inside the HEAD tag of a resource.

Arguments
$src
string
The CSS to be injected before the closing HEAD tag in an HTML response.
Details
visibility
public
final
false
static
false

regClientHTMLBlock

regClientHTMLBlock( string $html ) :

Register HTML to be injected before the closing BODY tag.

Arguments
$html
string
The HTML to be injected.
Details
visibility
public
final
false
static
false

regClientScript

regClientScript( string $src, boolean $plaintext = false ) :

Register JavaScript to be injected before the closing BODY tag.

Arguments
$src
string
The JavaScript to be injected before the closing BODY tag in an HTML response.
$plaintext
boolean
Optional param to treat the $src as plaintext rather than assuming it is JavaScript.
Details
visibility
public
final
false
static
false

regClientStartupHTMLBlock

regClientStartupHTMLBlock( string $html ) :

Register HTML to be injected before the closing HEAD tag.

Arguments
$html
string
The HTML to be injected.
Details
visibility
public
final
false
static
false

regClientStartupScript

regClientStartupScript( string $src, boolean $plaintext = false ) :

Register JavaScript to be injected inside the HEAD tag of a resource.

Arguments
$src
string
The JavaScript to be injected before the closing HEAD tag of an HTML response.
$plaintext
boolean
Optional param to treat the $src as plaintext rather than assuming it is JavaScript.
Details
visibility
public
final
false
static
false

reloadConfig

reloadConfig( ) : array

Reload the config settings.

Output
array
An associative array of configuration key/values
Details
visibility
public
final
false
static
false

removeAllEventListener

removeAllEventListener( ) :

Remove all registered events for the current request.

Details
visibility
public
final
false
static
false

removeEventListener

removeEventListener( string $event ) : boolean

Remove an event from the eventMap so it will not be invoked.

Arguments
$event
string
Output
boolean
false if the event parameter is not specified or is not present in the eventMap.
Details
visibility
public
final
false
static
false

runProcessor

runProcessor( string $action, array $scriptProperties = array, array $options = array ) : mixed

Loads and runs a specific processor.

Arguments
$action
string
The processor to run, eg: context/update
$scriptProperties
array
Optional. An array of parameters to pass to the processor.
$options
array
Optional. An array of options for running the processor, such as: - processors_path - If specified, will override the default MODX processors path. - location - A prefix to load processor files from, will prepend to the action parameter (Note: location will be deprecated in future Revolution versions.)
Output
mixed
The result of the processor.
Details
visibility
public
final
false
static
false

runSnippet

runSnippet( string $snippetName, array $params = array ) : string

Process and return the output from a PHP snippet by name.

Arguments
$snippetName
string
The name of the snippet.
$params
array
An associative array of properties to pass to the snippet.
Output
string
The processed output of the snippet.
Details
visibility
public
final
false
static
false

sanitize

sanitize( array $target, array|string $patterns = array, integer $depth = 3,  $nesting = 10 ) : array

Sanitize values of an array using regular expression patterns.

Arguments
$target
array
The target array to sanitize.
$patterns
arraystring
A regular expression pattern, or array of regular expression patterns to apply to all values of the target.
$depth
integer
The maximum recursive depth to sanitize if the target contains values that are arrays.
$nesting
Output
array
The sanitized array.
Details
visibility
public
final
false
static
true
static

sanitizeString

sanitizeString( string $str, array $chars = array, string $allowedTags ) : string

Sanitizes a string

Arguments
$str
string
The string to sanitize
$chars
array
An array of chars to remove
$allowedTags
string
A list of tags to allow.
Output
string
The sanitized string.
Details
visibility
public
final
false
static
false

sendError

sendError( string $type, array $options = array ) :

Send the user to a type-specific core error page and halt PHP execution.

Arguments
$type
string
The type of error to present.
$options
array
An array of options to provide for the error file.
Details
visibility
public
final
false
static
false

sendErrorPage

sendErrorPage( array $options = null ) :

Send the user to a MODX virtual error page.

Arguments
$options
array
An array of options to provide for the OnPageNotFound event and error page.
Details
visibility
public
final
false
static
false
uses
invokeEvent() The OnPageNotFound event is invoked before the error page is forwarded to.

sendForward

sendForward( integer $id, string $options = null ) :

Forwards the request to another resource without changing the URL.

Arguments
$id
integer
The resource identifier.
$options
string
An array of options for the process.
Details
visibility
public
final
false
static
false

sendRedirect

sendRedirect( string $url, array|boolean $options = false, string $type, string $responseCode ) :

Sends a redirect to the specified URL using the specified options.

Valid 'type' option values include: REDIRECT_REFRESH Uses the header refresh method REDIRECT_META Sends a a META HTTP-EQUIV="Refresh" tag to the output REDIRECT_HEADER Uses the header location method

REDIRECT_HEADER is the default.

Arguments
$url
string
The URL to redirect the client browser to.
$options
arrayboolean
An array of options for the redirect OR indicates if redirect attempts should be counted and limited to 3 (latter is deprecated usage; use count_attempts in options array).
$type
string
The type of redirection to attempt (deprecated, use type in options array).
$responseCode
string
The type of HTTP response code HEADER to send for the redirect (deprecated, use responseCode in options array)
Details
visibility
public
final
false
static
false

sendUnauthorizedPage

sendUnauthorizedPage( array $options = null ) :

Send the user to the MODX unauthorized page.

Arguments
$options
array
An array of options to provide for the OnPageUnauthorized event and unauthorized page.
Details
visibility
public
final
false
static
false
uses
invokeEvent() The OnPageUnauthorized event is invoked before the unauthorized page is forwarded to.

setDebug

setDebug( boolean|int $debug = true, boolean $stopOnNotice = false ) : boolean|int

Sets the debugging features of the modX instance.

Arguments
$debug
booleanint
Boolean or bitwise integer describing the debug state and/or PHP error reporting level.
$stopOnNotice
boolean
Indicates if processing should stop when encountering PHP errors of type E_NOTICE.
Output
boolean|int
The previous value.
Details
visibility
public
final
false
static
false

setPlaceholder

setPlaceholder( string $key, mixed $value ) :

Sets a placeholder value.

Arguments
$key
string
The unique string key which identifies the placeholder.
$value
mixed
The value to set the placeholder to.
Details
visibility
public
final
false
static
false

setPlaceholders

setPlaceholders( array|object $placeholders, string $namespace ) :

Sets a collection of placeholders stored in an array or as object vars.

An optional namespace parameter can be prepended to each placeholder key in the collection, to isolate the collection of placeholders.

Note that unlike toPlaceholders(), this function does not add separators between the namespace and the placeholder key. Use toPlaceholders() when working with multi-dimensional arrays or objects with variables other than scalars so each level gets delimited by a separator.

Arguments
$placeholders
arrayobject
An array of values or object to set as placeholders.
$namespace
string
A namespace prefix to prepend to each placeholder key.
Details
visibility
public
final
false
static
false

stripTags

stripTags(  $html,  $allowed,  $patterns = array,  $depth = 10 ) :

Strip unwanted HTML and PHP tags and supplied patterns from content.

Arguments
$html
$allowed
$patterns
$depth
Details
visibility
public
final
false
static
false

switchContext

switchContext( string $contextKey ) : boolean

Switches the primary Context for the modX instance.

Be aware that switching contexts does not allow custom session handling classes to be loaded. The gateway defines the session handling that is applied to a single request. To create a context with a custom session handler you must create a unique context gateway that initializes that context directly.

Arguments
$contextKey
string
The key of the context to switch to.
Output
boolean
True if the switch was successful, otherwise false.
Details
visibility
public
final
false
static
false

toPlaceholder

toPlaceholder( string $key, mixed $value, string $prefix, string $separator = ., boolean $restore = false ) : array

Recursively validates and sets placeholders appropriate to the value type passed.

Arguments
$key
string
The key identifying the value.
$value
mixed
The value to set.
$prefix
string
A string prefix to prepend to the key. Recursive calls prepend the parent keys as well.
$separator
string
A separator placed in between the prefix and the key. Default is a dot or period: '.'.
$restore
boolean
Set to true if you want overwritten placeholder values returned.
Output
array
A multi-dimensional array containing up to two elements: 'keys' which always contains an array of placeholder keys that were set, and optionally, if the restore parameter is true, 'restore' containing an array of placeholder values that were overwritten by the method.
Details
visibility
public
final
false
static
false

toPlaceholders

toPlaceholders( array|object $subject, string $prefix, string $separator = ., boolean $restore = false ) : array

Sets placeholders from values stored in arrays and objects.

Each recursive level adds to the prefix, building an access path using an optional separator.

Arguments
$subject
arrayobject
An array or object to process.
$prefix
string
An optional prefix to be prepended to the placeholder keys. Recursive calls prepend the parent keys.
$separator
string
A separator to place in between the prefixes and keys. Default is a dot or period: '.'.
$restore
boolean
Set to true if you want overwritten placeholder values returned.
Output
array
A multi-dimensional array containing up to two elements: 'keys' which always contains an array of placeholder keys that were set, and optionally, if the restore parameter is true, 'restore' containing an array of placeholder values that were overwritten by the method.
Details
visibility
public
final
false
static
false

toQueryString

toQueryString( array $parameters = array ) : string

Turn an associative array into a valid query string.

Arguments
$parameters
array
An associative array of parameters.
Output
string
A valid query string representing the parameters.
Details
visibility
public
final
false
static
true
static

unsetPlaceholder

unsetPlaceholder( string $key ) :

Unset a placeholder value by key.

Arguments
$key
string
The key of the placeholder to unset.
Details
visibility
public
final
false
static
false

unsetPlaceholders

unsetPlaceholders( string|array $keys ) :

Unset multiple placeholders, either by prefix or an array of keys.

Arguments
$keys
stringarray
A string prefix or an array of keys indicating the placeholders to unset.
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox 0.11.2.