Difference between revisions of "API:Path Constants and Globals"
|Line 33:||Line 33:|
Revision as of 19:47, 1 November 2012
[Valid for v1.3]
Providence uses several PHP constants, defined in /setup.php to locate various components it needs to run. These constants are available in any CollectiveAccess code you write. The following constants are available. All are absolute file paths.
|Constant||Description||Name in configuration files|
|__CA_BASE_DIR__||Path to the root directory of the installation.||ca_base_dir|
|__CA_APP_DIR__||Path to the [wiki:DirectoryLayout app directory] which contains much of the code that implements Providence||ca_app_dir|
|__CA_MODELS_DIR__||Path to the directory containing all model classes for the application. This is usually just equivalent to __CA_APP_DIR__ + "/models" as by default the models directory is located directly under the app directory.||ca_models_dir|
|__CA_LIB_DIR__||Path to the directory containing support libraries for the application. This is usually just equivalent to __CA_APP_DIR__ + "/lib" as by default the lib directory is located directly under the app directory.||ca_lib_dir|
|__CA_CONF_DIR__||Path to the directory containing all configuration files for the installation. This is usually just equivalent to __CA_APP_DIR__ + "/conf" as by default the conf directory is located directly under the app directory.||ca_conf_dir|
These constants are also available in all configuration files as <MACROS> in a slightly different format as specified in the table above (eg. <ca_models_dir>).
In general global variables are avoided in Providence. However, there are a few situations where it is convenient to use them. Since these globals are not defined in /setup.php they may not be available if you are writing code intended to be run from the command line.
|$g_locale_id||The user-selected locale_id (from the ca_locales table) to use for the user interface.||/index.php||Only available when request is invoked via index.php - a web request in other words|
|$g_locale||The user-selected locale (from the ca_locales table) as a code (ex. en_US for US English) to use for the user interface.||/index.php||Only available when request is invoked via index.php - a web request in other words|