Vufind: The library OPAC meets Web 2.0


 

Global Variables

VuFind uses a few important global variables that you may find helpful when building modules and maintaining the code.

Primary Globals

These two globals are the most important, and their use is encouraged:

  • $configArray
    This global contains the contents of the web/conf/config.ini file mapped into associative array format.
  • $interface
    This global is an instance of the UInterface class, used for passing information to the Smarty presentation layer. See the System Classes page for more details.

Secondary Globals

These globals are used in the code in a few places, but their use should be avoided unless absolutely necessary:

  • $translator
    This global is an instance of the I18N_Translator class, used for translating presentation-layer text into various languages. This should be needed only rarely outside of the presentation templates.
  • $user
    This global is an object representing the current logged-in user, if one exists. User login code may be refactored, so use this sparingly.

Accessing a Global

Remember that in PHP, you need to declare globals at the top of any functions or methods that use them. For example:

function dumpConfigArray() 
{
    global $configArray;
 
    print_r($configArray);
}
 
global_variables.txt · Last modified: 2009/07/24 11:44 by demiankatz
 
Recent changes RSS feed Driven by DokuWiki