You are here

function themekey_property_value in ThemeKey 6.2

Same name and namespace in other branches
  1. 6.4 themekey_base.inc \themekey_property_value()
  2. 6.3 themekey_base.inc \themekey_property_value()
  3. 7.3 themekey_base.inc \themekey_property_value()
  4. 7 themekey_base.inc \themekey_property_value()
  5. 7.2 themekey_base.inc \themekey_property_value()

Detects if a ThemeKey property's value for the current page request.

Parameters

$parameters: reference to an array containing all ThemeKey properties an their values

$property: the name of the property as string

Return value

The value of the property:

  • string i it's a single value
  • array of strings if there're multiple values
  • NULL if no value
2 calls to themekey_property_value()
themekey_debug_properties in ./themekey_debug.module
Iterates over all ThemeKey Properties and prints out their current values.
themekey_match_condition in ./themekey_base.inc
Detects if a ThemeKey rule matches to the current page request.

File

./themekey_base.inc, line 410
The functions in this file are the back end of ThemeKey.

Code

function themekey_property_value(&$parameters, $property) {

  // TODO Warning if property is not part of variable_get('themekey_attributes')
  // Property value is available directly
  if (isset($parameters[$property])) {
    return $parameters[$property];
  }
  $parameters[$property] = NULL;
  $src_candidates = array();
  $maps = variable_get('themekey_maps', array());
  foreach ($maps as $pos => $map) {
    if ($map['dst'] == $property) {
      if (!empty($parameters[$map['src']])) {
        $map_func = $map['callback'];
        $parameters[$property] = $map_func($parameters[$map['src']], $parameters);
        break;
      }
      $src_candidates[$pos] = $map['src'];
    }
  }
  if (is_null($parameters[$property]) && !empty($src_candidates)) {
    foreach ($src_candidates as $pos => $src) {
      $return = themekey_property_value($parameters, $src);
      if ($return) {
        $map_func = $maps[$pos]['callback'];
        $parameters[$property] = $map_func($return, $parameters);
        break;
      }
    }
  }
  return $parameters[$property];
}