function _styles_drupal_static in Styles 6
Same name and namespace in other branches
- 6.2 includes/styles.variables.inc \_styles_drupal_static()
Backport of Drupal 7's drupal_static function.
5 calls to _styles_drupal_static()
- styles_containers in ./
styles.module - Get an array of all defined style containers.
- styles_get_registered_classes in ./
styles.module - Builds a registry of Style classes.
- styles_get_styles_class_by_class_name in ./
styles.module - Return the registered Styles class definition specified by name.
- styles_presets in ./
styles.module - Return an array of all style presets.
- styles_styles in ./
styles.module - Get an array of all available styles.
File
- includes/
styles.variables.inc, line 157 - styles.variables.inc Variable defaults for Styles.
Code
function &_styles_drupal_static($name, $default_value = NULL, $reset = FALSE) {
static $data = array(), $default = array();
if (!isset($name)) {
// All variables are reset. This needs to be done one at a time so that
// references returned by earlier invocations of drupal_static() also get
// reset.
foreach ($default as $name => $value) {
$data[$name] = $value;
}
// As the function returns a reference, the return should always be a
// variable.
return $data;
}
if ($reset) {
// The reset means the default is loaded.
if (array_key_exists($name, $default)) {
$data[$name] = $default[$name];
}
else {
// Reset was called before a default is set and yet a variable must be
// returned.
return $data;
}
}
elseif (!array_key_exists($name, $data)) {
// Store the default value internally and also copy it to the reference to
// be returned.
$default[$name] = $data[$name] = $default_value;
}
return $data[$name];
}