array( * 'name' => 'stylename-1', * 'module' => 'mymodule', * 'storage' => [STYLES_STORAGE_DEFAULT|STYLES_STORAGE_NORMAL|STYLES_STORAGE_OVERRIDE], * 'sid' => [serial-style-id], * 'field_types' => array('nodereference'), * 'effects' => array( * [unique-effect-id] => array( * 'module' => 'mymodule', * 'name' => 'effect-1', * 'data' => array( /* whatever needs storage here */), * ), * ), * ), * * @return * An array of styles keyed by the style ID (sid). * @see styles_style_load() */ function styles() { $styles = &drupal_static(__FUNCTION__); // Grab from cache or build the array. if (!isset($styles)) { if ($cache = cache_get('styles', 'cache')) { $styles = $cache->data; } else { $styles = array(); // Select the module-defined styles. foreach (module_implements('styles_defaults') as $module) { $module_styles = module_invoke($module, 'styles_defaults'); foreach ($module_styles as $style_name => $style) { $style['name'] = $style_name; $style['module'] = $module; $style['storage'] = STYLES_STORAGE_DEFAULT; foreach ($style['effects'] as $seid => $effect) { $definition = styles_effect_definition_load($effect['name']); $effect = array_merge($definition, $effect); $effect['seid'] = $seid; $style['effects'][$seid] = $effect; } $styles[$style_name] = $style; } } // Select all the user-defined styles. $user_styles = db_select('styles', NULL, array('fetch' => PDO::FETCH_ASSOC)) ->fields('styles') ->orderBy('name') ->execute() ->fetchAllAssoc('name', PDO::FETCH_ASSOC); // Allow the user styles to override the module styles. foreach ($user_styles as $style_name => $style) { $style['module'] = NULL; $style['storage'] = STYLES_STORAGE_NORMAL; $style['effects'] = styles_effects($style); if (isset($styles[$style_name]['module'])) { $style['module'] = $styles[$style_name]['module']; $style['storage'] = STYLES_STORAGE_OVERRIDE; } $styles[$style_name] = $style; } drupal_alter('styles', $styles); cache_set('styles', $styles); } } return $styles; }