You are here

function styles_style_load in Styles 7.2

Load a style by style name or ID. May be used as a loader for menu items.

Parameters

$field_type: The field type for this style.

$name: The name of the style.

$sid: Optional. The numeric id of a style if the name is not known.

$include: If set, this loader will restrict to a specific type of style, may be one of the defined style storage constants.

Return value

A style array containing the following keys:

  • "sid": The unique style ID.
  • "name": The unique style name.

If the style name or ID is not valid, an empty array is returned.

3 calls to styles_style_load()
styles_style_features_revert in includes/styles.features.inc
Implements hook_features_revert().
styles_style_save in ./styles.module
styles_ui_style_edit_form in contrib/styles_ui/styles_ui.admin.inc
Callback for the style edit form.

File

./styles.module, line 525
Bundles similar display formatters together.

Code

function styles_style_load($field_type, $name = NULL, $sid = NULL, $include = NULL) {
  $styles = styles_default_styles($field_type);

  // If retrieving by name.
  if (isset($name) && isset($styles['styles'][$name])) {
    $style = $styles['styles'][$name];
  }

  // If retrieving by style id.
  if (!isset($name) && isset($sid)) {
    foreach ($styles['styles'] as $name => $database_style) {
      if (isset($database_style['sid']) && $database_style['sid'] == $sid) {
        $style = $database_style;
        break;
      }
    }
  }

  // Restrict to the specific type of flag. This bitwise operation basically
  // states "if the storage is X, then allow".
  if (isset($style) && (!isset($include) || $style['storage'] & (int) $include)) {
    return $style;
  }

  // Otherwise the style was not found.
  return array();
}