Access point / Container for global data
CONTENIDO used to use a huge amount of global variables. This, for sure, is not the best approach of handling data that has to be generally available in every corner of the code. As PHP is going to banish these beloved variables in a future version, we had to develop another solution. This brought us to the idea to build a registry holding all this data. In order to allow a smooth migration the registry already offers an easy read access to this data although the data itself is still global. This will change in a future version of CONTENIDO.
The registries heart is the protected method _fetchGlobalVariable() which provides access to global data and allows to define a default value if the requested data does not exist. All other getters are build ontop of this method. A rough overview of the data that can be accessed through the registry:
global | method | note |
---|
contenido | getBackendSessionId | Â |
belang | getBackendLanguage | Â |
edit | isBackendEditMode | default false |
lang | getLanguageId | default load_lang |
client | getClientId | default load_client |
idart | getArticleId | default 0 |
idartlang | getArticleLanguageId | default 0 |
idcat | getCategoryId | default 0 |
idcatlang | getCategoryLanguageId | default 0 |
idcatart | getCategoryArticleId | default 0 |
cCurrentModule | getCurrentModuleId | default 0; This function will work only within module code. |
cCurrentContainer | getCurrentContainerId | default 0; This function will work only within module code. |
sess | getSession | Â |
auth | getAuth | Â |
perm | getPerm | Â |
cfg | getConfig | default array() |
cfgClient | getClientConfig | default array(); can take a parameter $clientId in order to return config of this client |
tab | getDbTableName | sfdg |
_cecRegistry | getCecRegistry | Â |
Convenience methods
Furthermore the registry is flavoured with some convenience methods to ease the development of modules and plugins.
method | note |
---|
getLanguage | Returns an instance of class cApiLanguage with the ID that is returned by getLanguageId. |
getClient | Returns an instance of class cApiClient with the ID that is returned by getClientId. |
getArticle | Returns an instance of class cApiArticle with the ID that is returned by getArticleId. |
getArticleLanguage | Returns an instance of class cApiArticleLanguage with the ID that is returned by getArticleLanguageId. |
getCategory | Returns an instance of class cApiCategory with the ID that is returned by getCategoryId. |
getCategoryLanguage | Returns an instance of class cApiCategoryLanguage with the ID that is returned by getCategoryLanguageId. |
getCategoryArticle | Returns an instance of class cApiCategoryArticle with the ID that is returned by getCategoryArticleId. |
method | note |
---|
getBackendPath | $cfg['path']['contenido'] |
getBackendUrl | $cfg['path']['contenido_fullhtml'] |
getFrontendPath | $cfgClient[$client]['path']['frontend'] |
getFrontendUrl | $cfgClient[$client]['path']['htmlpath'] |
method | note |
---|
bootstrap | Bootstraps the CONTENIDO framework and initializes the global variables sess, auth and perm. |
shutdown | Shutdowns the CONTENIDO framework on page close. |
addInfoMessage | Stores an information massage in the cRegistry. |
getInfoMessages | Returns an array with information messages. |
addErrorMessage | Stores an error massage in the cRegistry. |
getErrorMessages | Returns an array with error messages. |
addWarningMessage | Stores an warning massage in the cRegistry. |
getWarningMessages | Returns an array with warning messages. |
isTrackingAllowed | whether tracking is allowed by the DNT header |