function block_class_styles_info in Block Class Styles 7.2
Same name and namespace in other branches
- 7 block_class_styles.module \block_class_styles_info()
Return an array of style presets
Parameters
boolean $include_hidden Include hiden styles:
Return value
array Keys are classes, values are styles
Related topics
5 calls to block_class_styles_info()
- block_class_styles_admin_settings in ./block_class_styles.admin.inc 
- Form builder. Configure my_module.
- block_class_styles_admin_settings_validate in ./block_class_styles.admin.inc 
- Form validation handler for block_class_styles_admin_settings_validate().
- block_class_styles_form_alter in ./block_class_styles.module 
- Implements hook_form_alter().
- block_class_styles_get_css_by_style in ./block_class_styles.module 
- Returns an array of css classes for a given style name.
- block_class_styles_get_style in ./block_class_styles.module 
- Return a style by it's css
File
- ./block_class_styles.module, line 184 
- Base module file for block_class_styles
Code
function block_class_styles_info($include_hidden = FALSE) {
  static $drupal_static_fast;
  if (!isset($drupal_static_fast)) {
    $drupal_static_fast['presets'] =& drupal_static(__FUNCTION__, NULL);
  }
  $presets =& $drupal_static_fast['presets'];
  if (!isset($presets)) {
    $presets = array();
    // Load distinct classes and groupings of classes from blocks table; this
    // makes sure that we have a style for every class or class group that is
    // currently assigned to a block.
    $classes = db_select(_block_class_tablename(), 'b')
      ->fields('b', array(
      'css_class',
    ))
      ->condition('css_class', '', '!=')
      ->distinct()
      ->execute()
      ->fetchCol();
    foreach ($classes as $class) {
      $presets[$class] = ucwords(preg_replace('/[_-]/', ' ', $class));
    }
    // Now match to our presets if possible; this will overwrite the automatic
    // naming convention from above and add any styles that have been defined
    // but not yet assigned.
    $presets = variable_get('block_class_styles_presets', array()) + $presets;
    // Remove any hidden styles if asked.
    $hidden = variable_get('block_class_styles_hidden', array());
    if (!$include_hidden) {
      $presets = array_diff_key($presets, $hidden);
    }
    // Let other modules alter this list
    drupal_alter('block_class_styles_info', $presets);
    $presets = (array) $presets;
  }
  return $presets;
}