Exemple #1
0
/**
 * Generate initial grid info.
 */
function fusion_core_grid_info()
{
    global $theme_key;
    $grid =& drupal_static(__FUNCTION__);
    if (isset($grid)) {
        return $grid;
    }
    $grid = array();
    if (theme_get_setting('responsive_enabled') && module_exists('fusion_accelerator')) {
        $grid['type'] = 'responsive';
        $grid['name'] = 'grid' . theme_get_setting('responsive_columns') . '-';
        $grid['fixed'] = TRUE;
        $grid['width'] = theme_get_setting('responsive_columns');
    } else {
        $grid['name'] = substr(theme_get_setting('theme_grid'), 0, 7);
        $grid['type'] = substr(theme_get_setting('theme_grid'), 7);
        $grid['fixed'] = substr(theme_get_setting('theme_grid'), 7) != 'fluid' ? TRUE : FALSE;
        $grid['width'] = (int) substr($grid['name'], 4, 2);
    }
    // Set sidebar width if this is the block demonstration page.
    global $theme;
    $item = menu_get_item();
    if ($item['path'] == 'admin/structure/block/demo/' . $theme) {
        $grid['sidebar_first_width'] = theme_get_setting('sidebar_first_width');
        $grid['sidebar_second_width'] = theme_get_setting('sidebar_second_width');
    } else {
        $grid['sidebar_first_width'] = fusion_core_block_list('sidebar_first') ? theme_get_setting('sidebar_first_width') : 0;
        $grid['sidebar_second_width'] = fusion_core_block_list('sidebar_second') ? theme_get_setting('sidebar_second_width') : 0;
    }
    $grid['regions'] = array();
    $regions = array_keys(system_region_list($theme_key, REGIONS_VISIBLE));
    $nested_regions = theme_get_setting('grid_nested_regions');
    $adjusted_regions = theme_get_setting('grid_adjusted_regions');
    foreach ($regions as $region) {
        $region_style = 'full-width';
        $region_width = $grid['width'];
        if ($region == 'sidebar_first' || $region == 'sidebar_second') {
            $region_width = $region == 'sidebar_first' ? $grid['sidebar_first_width'] : $grid['sidebar_second_width'];
        }
        if ($nested_regions && in_array($region, $nested_regions)) {
            $region_style = 'nested';
            if ($adjusted_regions && in_array($region, array_keys($adjusted_regions))) {
                foreach ($adjusted_regions[$region] as $adjacent_region) {
                    $region_width = $region_width - $grid[$adjacent_region . '_width'];
                }
            }
        }
        $grid['regions'][$region] = array('width' => $region_width, 'style' => $region_style, 'total' => count(fusion_core_block_list($region)), 'count' => 0);
    }
    // Adjustments for fluid width regions & groups
    $grid['fluid_adjustments'] = array();
    // Regions
    $adjusted_regions_fluid = theme_get_setting('grid_adjusted_regions_fluid') ? theme_get_setting('grid_adjusted_regions_fluid') : array();
    foreach (array_keys($adjusted_regions_fluid) as $adjusted_region) {
        $width = $grid['width'];
        foreach ($adjusted_regions_fluid[$adjusted_region] as $region) {
            $width = $width - $grid['regions'][$region]['width'];
            // Subtract regions outside parent group to get correct parent width
        }
        $grid['fluid_adjustments'][$adjusted_region] = round($grid['regions'][$adjusted_region]['width'] / $width * 100, 2);
    }
    // Groups
    $adjusted_groups_fluid = theme_get_setting('grid_adjusted_groups_fluid') ? theme_get_setting('grid_adjusted_groups_fluid') : array();
    foreach (array_keys($adjusted_groups_fluid) as $adjusted_group) {
        $width = 100;
        foreach ($adjusted_groups_fluid[$adjusted_group] as $region) {
            $width = $width - $grid['fluid_adjustments'][$region];
            // Subtract previously calculated sibling region fluid adjustments
        }
        $grid['fluid_adjustments'][$adjusted_group] = $width;
        // Group gets remaining width
    }
    return $grid;
}
Exemple #2
0
/**
 * Block region grid info function
 * Defaults match grid_row widths set in preprocess_page()
 */
function fusion_core_set_regions($grid_width, $sidebar_first_width, $sidebar_last_width)
{
    $sidebar_total = $sidebar_first_width + $sidebar_last_width;
    $regions = array('header_top' => array('width' => $grid_width, 'total' => count(fusion_core_block_list('header_top')), 'count' => 0), 'header' => array('width' => $grid_width, 'total' => count(fusion_core_block_list('header')), 'count' => 0), 'preface_top' => array('width' => $grid_width, 'total' => count(fusion_core_block_list('preface_top')), 'count' => 0), 'preface_bottom' => array('width' => $grid_width - $sidebar_first_width, 'total' => count(fusion_core_block_list('preface_bottom')), 'count' => 0), 'sidebar_first' => array('width' => $sidebar_first_width, 'total' => count(fusion_core_block_list('sidebar_first')), 'count' => 0), 'content_top' => array('width' => $grid_width - $sidebar_total, 'total' => count(fusion_core_block_list('content_top')), 'count' => 0), 'content' => array('width' => $grid_width - $sidebar_total, 'total' => count(fusion_core_block_list('content')), 'count' => 0), 'node_top' => array('width' => $grid_width - $sidebar_total, 'total' => count(fusion_core_block_list('node_top')), 'count' => 0), 'node_bottom' => array('width' => $grid_width - $sidebar_total, 'total' => count(fusion_core_block_list('node_bottom')), 'count' => 0), 'content_bottom' => array('width' => $grid_width - $sidebar_total, 'total' => count(fusion_core_block_list('content_bottom')), 'count' => 0), 'sidebar_last' => array('width' => $sidebar_last_width, 'total' => count(fusion_core_block_list('sidebar_last')), 'count' => 0), 'postscript_top' => array('width' => $grid_width - $sidebar_first_width, 'total' => count(fusion_core_block_list('postscript_top')), 'count' => 0), 'postscript_bottom' => array('width' => $grid_width, 'total' => count(fusion_core_block_list('postscript_bottom')), 'count' => 0), 'footer' => array('width' => $grid_width, 'total' => count(fusion_core_block_list('footer')), 'count' => 0));
    return $regions;
}
Exemple #3
0
/**
 * Generate initial grid info
 */
function fusion_core_grid_info() {
  global $theme_key;
  static $grid;

  if (!isset($grid)) {
    $grid = array();
    $grid['name'] = substr(theme_get_setting('theme_grid'), 0, 7);
    $grid['type'] = substr(theme_get_setting('theme_grid'), 7);
    $grid['fixed'] = (substr(theme_get_setting('theme_grid'), 7) != 'fluid') ? true : false;
    $grid['width'] = (int)substr($grid['name'], 4, 2);
    $grid['sidebar_first_width'] = (fusion_core_block_list('sidebar_first')) ? theme_get_setting('sidebar_first_width') : 0;
    $grid['sidebar_second_width'] = (fusion_core_block_list('sidebar_second')) ? theme_get_setting('sidebar_second_width') : 0;
    $grid['regions'] = array();
    $regions = array_keys(system_region_list($theme_key, REGIONS_VISIBLE));
    $nested_regions = theme_get_setting('grid_nested_regions');
    $adjusted_regions = theme_get_setting('grid_adjusted_regions');
    foreach ($regions as $region) {
      $region_style = 'full-width';
      $region_width = $grid['width'];
      if ($region == 'sidebar_first' || $region == 'sidebar_second') {
        $region_width = ($region == 'sidebar_first') ? $grid['sidebar_first_width'] : $grid['sidebar_second_width'];
      }
      if ($nested_regions && in_array($region, $nested_regions)) {
        $region_style = 'nested';
        if ($adjusted_regions && in_array($region, array_keys($adjusted_regions))) {
          foreach ($adjusted_regions[$region] as $adjacent_region) {
            $region_width = $region_width - $grid[$adjacent_region . '_width'];
          }
        }
      }
      $grid['regions'][$region] = array('width' => $region_width, 'style' => $region_style, 'total' => count(fusion_core_block_list($region)), 'count' => 0);
    }

    // Adjustments for fluid width regions & groups
    $grid['fluid_adjustments'] = array();
    // Regions
    $adjusted_regions_fluid = (theme_get_setting('grid_adjusted_regions_fluid')) ? theme_get_setting('grid_adjusted_regions_fluid') : array();
    foreach (array_keys($adjusted_regions_fluid) as $adjusted_region) {
      $width = $grid['width'];
      foreach ($adjusted_regions_fluid[$adjusted_region] as $region) {
        $width = $width - $grid['regions'][$region]['width'];         // Subtract regions outside parent group to get correct parent width
      }
      $grid['fluid_adjustments'][$adjusted_region] = round(($grid['regions'][$adjusted_region]['width'] / $width) * 100, 2);
    }
    // Groups
    $adjusted_groups_fluid = (theme_get_setting('grid_adjusted_groups_fluid')) ? theme_get_setting('grid_adjusted_groups_fluid') : array();
    foreach (array_keys($adjusted_groups_fluid) as $adjusted_group) {
      $width = 100;
      foreach ($adjusted_groups_fluid[$adjusted_group] as $region) {
        $width = $width - $grid['fluid_adjustments'][$region];         // Subtract previously calculated sibling region fluid adjustments
      }
      $grid['fluid_adjustments'][$adjusted_group] = $width;            // Group gets remaining width
    }
  }
  return $grid;
}