Base XenForo application class.

Sets up the environment as necessary and acts as the registry for the application. Can broker to the autoload as well.

package XenForo_Core

 Methods

Add a lazy loader to the application registry.

addLazyLoader(string $index, callback $callback) 

This lazy loader callback will be called if the specified index is not in the registry.

The 3rd argument and on will be passed to the lazy loader callback.

Parameters

$index

string

Index to assign lazy loader to

$callback

callback

Callback to call when triggered

Returns a version of the input $data that contains only the array keys defined in $keys

arrayFilterKeys(array $data, array $keys) : array
Static

Example: arrayFilterKeys(array('a' => 1, 'b' => 2, 'c' => 3), array('b', 'c')) Returns: array('b' => 2, 'c' => 3)

Parameters

$data

array

$keys

array

Returns

array$data

Helper method to autoload a class.

autoload(string $class) : boolean
Static

Could simply call the autoloader directly but this method is recommended to reduce dependencies.

Parameters

$class

string

Class to load

Returns

boolean

Begin the application.

beginApplication(string $configDir, string $rootDir, boolean $loadDefaultData) 

This causes the environment to be setup as necessary.

Parameters

$configDir

string

Path to application configuration directory. See {@link $_configDir}.

$rootDir

string

Path to application root directory. See {@link $_rootDir}.

$loadDefaultData

boolean

True to load default data (config, DB, etc)

Determines whether we should try to write to the development files.

canWriteDevelopmentFiles() : boolean
Static

Returns

boolean

Returns true if the application is in debug mode.

debugMode() : boolean
Static

Returns

boolean

Disables our PHP error handler, in favor of a previously registered one (or the default PHP error handler).

disablePhpErrorHandler() 
Static

Enables our PHP error handler.

enablePhpErrorHandler() 
Static

Generates a psuedo-random string of the specified length.

generateRandomString(integer $length) : string
Static

Parameters

$length

integer

Returns

string

getter method, basically same as offsetGet().

get(string $index) : mixed
Static

This method can be called from an object of type Zend_Registry, or it can be called statically. In the latter case, it uses the default static instance stored in the class.

Parameters

$index

string
  • get the value associated with $index

Exceptions

\Zend_Exception if no entry is registerd for $index.

Returns

mixed

getCache()

getCache() : \Zend_Cache_Core | boolean
Static

Returns

\Zend_Cache_Coreboolean

getConfig()

getConfig() : \Zend_Config
Static

Returns

\Zend_Config

Gets the path to the configuration directory.

getConfigDir() : string

Returns

string

getDb()

getDb() : \Zend_Db_Adapter_Abstract
Static

Returns

\Zend_Db_Adapter_Abstract

getOptions()

getOptions() : \XenForo_Options
Static

Gets the request paths from the specified request object.

getRequestPaths(\Zend_Controller_Request_Http $request) : array
Static

Parameters

$request

\Zend_Controller_Request_Http

Returns

arrayKeys: basePath, host, protocol, fullBasePath, requestUri

Gets the path to the application root directory.

getRootDir() : string

Returns

string

getSession()

getSession() : \XenForo_Session
Static

Gets the specified simple cache data.

getSimpleCacheData(string $key) : mixed | false
Static

The simple cache is for data that you want available on on pages, but don't need to special rebuild behaviors for.

Parameters

$key

string

Returns

mixedfalseFalse if not in the cache

Attempts to get the specified index.

getWithFallback(string $index, callback $callback, array $args) : mixed
Static

If it cannot be found, the callback is called and the result from the callback is set into the registry for that index.

Parameters

$index

string

Index to look for

$callback

callback

Callback function to call if not found

$args

array

Arguments to pass to callback

Returns

mixed

Gzips the given content if the browser supports it.

gzipContentIfSupported(string $content) : array
Static

Parameters

$content

string

Content to gzip; this will be modified if necessary

Returns

arrayList of HTTP headers to add

Default exception handler.

handleException(\Exception $e) 
Static

Parameters

Handler for set_error_handler to convert notices, warnings, and other errors into exceptions.

handlePhpError(integer $errorType, string $errorString, string $file, integer $line) 
Static

Parameters

$errorType

integer

Type of error (one of the E_* constants)

$errorString

string

$file

string

$line

integer

Helper function to initialize the application.

initialize(string $configDir, string $rootDir, boolean $loadDefaultData) 
Static

Parameters

$configDir

string

Path to application configuration directory. See {@link $_configDir}.

$rootDir

string

Path to application root directory. See {@link $_rootDir}.

$loadDefaultData

boolean

True to load default data (config, DB, etc)

Execute lazy loader for an index if there is one.

lazyLoad(string $index, mixed $return) : boolean

The loaded data is returned via a reference parameter, not the return value of the method. The return value is true only if the lazy loader was executed.

Once called, the data is set to the registry and the lazy loader is removed.

Parameters

$index

string

Index to lazy load

$return

mixed

By ref; data returned by lazy loader

Returns

booleanTrue if a lazy loader was called

Load the cache object.

loadCache(\Zend_Config $cacheConfig) : \Zend_Cache_Core | \Zend_Cache_Frontend | false

Parameters

$cacheConfig

\Zend_Configuration

Configuration to use

Returns

\Zend_Cache_Core\Zend_Cache_Frontendfalse

Load the configuration file.

loadConfig() : \Zend_Config

Mixes in over top of the default values. Provided a default is specified in loadDefaultConfig, all elements available to the config will always be defined. Non-default elements may still be defined in the loaded configuration.

Returns

\Zend_Config

Load the database object.

loadDb(\Zend_Config $dbConfig) : \Zend_Db_Adapter_Abstract

Parameters

$dbConfig

\Zend_Configuration

Configuration to use

Returns

\Zend_Db_Adapter_Abstract

Load the default configuration.

loadDefaultConfig() : \Zend_Config

User-specified versions will override this.

Returns

\Zend_Config

Loads the default data for the application (config, DB, options, etc).

loadDefaultData() 

Loads the list of options from the cache if possible and rebuilds it from the DB if necessary.

loadOptions() : \XenForo_Options

Loads the request paths from a default request object.

loadRequestPaths() : array

Returns

array

Loads simple cache data from the source.

loadSimpleCache() : array

Returns

array

This is a simplified version of a function similar to array_merge_recursive.

mapMerge(array $first, array $second) : array
Static

It is designed to recursively merge associative arrays (maps). If each array shares a key, that key is recursed and the child keys are merged.

This function does not handle merging of non-associative arrays (numeric keys) as a special case.

More than 2 arguments may be passed if desired.

Parameters

$first

array

$second

array

Returns

array

Parses a query string (x=y&a=b&c[]=d) into a structured array format.

parseQueryString(string $string) : array
Static

Parameters

$string

string

Returns

array

Removes the lazy loader from the specified index.

removeLazyLoader(string $index) : boolean

Parameters

$index

string

Index to remove from

Returns

boolean

Resolves dynamic, run time inheritance for the specified class.

resolveDynamicClass(string $class, string $type, string | false $fakeBase) : false | string
Static

The classes to be loaded for this base class are grabbed via the event. These classes must inherit from from XFCP_x, which is a non-existant class that is dynamically created, inheriting from the correct class as needed.

If a fake base is needed when the base class doesn't exist, and there are no classes extending it, false will still be returned! This prevents an unnecessary eval.

Parameters

$class

string

Name of class

$type

string

Type of class (for determining event to fire)

$fakeBase

stringfalse

If the specified class doesn't exist, an alternative base can be specified

Returns

falsestringFalse or name of class to instantiate

Sets the debug mode value.

setDebugMode(boolean $debug) 
Static

Parameters

$debug

boolean

Setup necessary system defaults based on the options.

setDefaultsFromOptions(\XenForo_Options $options) 
Static

Parameters

$options

\XenForo_Options

Sets the memory limit.

setMemoryLimit(integer $limit) 
Static

Will not shrink the limit.

Parameters

$limit

integer

Limit must be given in integer (byte) format.

Sets the specified simple cache data.

setSimpleCacheData(string $key, mixed $value) 
Static

This data will be persisted over pages indefinitely. Values of false will remove the cache data.

Parameters

$key

string

$value

mixed

If false, the specified cache key is removed

Helper method to remove the result of magic_quotes_gpc being applied to the input super globals

undoMagicQuotes(array $array, integer $depth) 
Static

Parameters

$array

array

The array to have slashes stripped, this is passed by reference

$depth

integer

Recursion depth to prevent malicious use

 Properties

 

$externalDataPath : string

Must be web accessible and server-writable. Examples 'data', 'foo/bar/data', '../path/to/thingy'.

 

$externalDataUrl : string

Can be relative or absolute, but must point to the web-accessible location referred-to by $externalDataPath.

 

$host : string
 

$integerSentinel : string
 

$jQueryVersion : string

See XenForo_Dependencies_Public::getJquerySource()

 

$javaScriptUrl : string

Can be absolute or relative.

 

$jsVersion : string
 

$secure : boolean
 

$time : integer

This should be used whenever 'now' needs to be referred to.

 

$version : string: integer

These are used for visual output and installation/upgrading.

 

$versionId 
 

$_classCache : array
 

$_configDir : string
 

$_debug : boolean
 

$_handlePhpError : boolean

Otherwise, they will be deferred to any previously registered handler (probably PHP's).

 

$_initialized : boolean
 

$_lazyLoaders : array

When a lazy loader is called, it is removed from the list. Key is the index and value is an array: 0 => callback 1 => array of arguments

 

$_memoryLimit 
 

$_randomData : string

String of hex characters.

 

$_rootDir : string

Specific directories will be looked for within this.

 Constants

 

URL_ID_DELIMITER

URL_ID_DELIMITER