Projet

Général

Profil

Révision ba3b3627

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/ds/ds.module
736 736
    if (!empty($layout['settings']['layout_attributes_merge'])) {
737 737
      // Handle classes separately.
738 738
      if (isset($vars['attributes_array']['class'])) {
739
        $vars['classes_array'] += $vars['attributes_array']['class'];
739
        $vars['classes_array'] = array_unique(array_merge($vars['classes_array'], $vars['attributes_array']['class']));
740 740
        unset($vars['attributes_array']['class']);
741 741
      }
742 742
      $vars['layout_attributes'] .= ' ' . drupal_attributes($vars['attributes_array']);
......
925 925
 * Render a block field.
926 926
 */
927 927
function ds_render_block_field($field) {
928
  // Invoke the block_view hook of the module.
928
  global $theme_key;
929 929
  list($module, $delta) = explode('|', $field['properties']['block']);
930
  $block = module_invoke($module, 'block_view', $delta);
931

  
932
  // Get contextual links.
933
  $contextual_links = array();
934
  $contextual = module_exists('contextual') && user_access('access contextual links');
935
  if ($contextual) {
936
    if (isset($block['content']) && is_array($block['content']) && isset($block['content']['#contextual_links'])) {
937
      $contextual_links = $block['content']['#contextual_links'];
938
    }
930

  
931
  // Load the block
932
  $result = db_select('block', 'b')
933
    ->fields('b')->condition('b.theme', $theme_key)->condition('b.module', $module)->condition('b.delta', $delta)->addTag('block_load')->addTag('translatable')->execute();
934
  $block_info = $result->fetchAllAssoc('bid');
935

  
936
  // Enable the block
937
  if ($block_info[key($block_info)]->status == 0) {
938
    $block_info[key($block_info)]->status = 1;
939 939
  }
940 940

  
941
  // Render the block content.
942
  if (isset($block['content']) && is_array($block['content'])) {
943
    $block['content'] = drupal_render($block['content']);
941
  // Process the block if it respects visibility settings
942
  if (isset($field['properties']['block_visibility']) && $field['properties']['block_visibility']) {
943
    drupal_alter('block_list', $block_info);
944 944
  }
945 945

  
946
  // Go through in case we have actual content.
947
  if (!empty($block['content'])) {
946
  // Simulate _block_load_blocks() return, containing only our block.
947
  $block = array_shift($block_info);
948 948

  
949
    // Make sure subject is set.
950
    if (!isset($block['subject'])) {
951
      $block['subject'] = '';
952
    }
953

  
954
    global $theme_key;
949
  // Render the block field
950
  if (isset($block)) {
951
    $key = $module . '_' . $delta;
955 952
    if (module_exists('block')) {
956
      $full_block = db_query("SELECT * FROM {block} WHERE module = :module AND delta = :delta AND theme = :theme", array(':module' => $module, ':delta' => $delta, ':theme' => $theme_key))->fetchObject();
957
    }
958
    if (!empty($full_block)) {
959
      if ($full_block->title == '<none>') {
960
        $block['subject'] = '';
961
      }
962
      elseif (!empty($full_block->title)) {
963
        $block['subject'] = $full_block->title;
964
      }
965
    }
966

  
967
    // i18n support.
968
    if (function_exists('i18n_block_block_view_alter')) {
969

  
970
      // Check language visibility.
971
      global $language;
972
      static $block_languages = FALSE;
973
      if (!$block_languages) {
974
        $block_languages = array();
975
        $result = db_query('SELECT module, delta, language FROM {i18n_block_language}');
976
        foreach ($result as $record) {
977
          $block_languages[$record->module][$record->delta][$record->language] = TRUE;
978
        }
979
      }
980
      if (isset($block_languages[$module][$delta]) && !isset($block_languages[$module][$delta][$language->language])) {
981
        return;
982
      }
983

  
984
      // Translate.
985
      if (!empty($full_block->i18n_mode)) {
986
        i18n_block_block_view_alter($block, $full_block);
987
        if (!empty($block['title'])) {
988
          $block['subject'] = $block['title'];
989
        }
953
      $region_blocks = _block_render_blocks(array($key => $block));
954
      switch ($field['properties']['block_render']) {
955
        case DS_BLOCK_TEMPLATE:
956
          $renderable_block = _block_get_renderable_array($region_blocks);
957
          return drupal_render($renderable_block);
958
          break;
959
        case DS_BLOCK_TITLE_CONTENT:
960
          if (isset($block->subject) && isset($block->content['#markup'])) {
961
            return '<h2 class="block-title">' . $block->subject . '</h2>' . $block->content['#markup'];
962
          }
963
          break;
964
        case DS_BLOCK_CONTENT:
965
          if (isset($block->content['#markup'])) {
966
            return $block->content['#markup'];
967
          }
968
          break;
990 969
      }
991 970
    }
992

  
993
    $block = (object) $block;
994
    switch ($field['properties']['block_render']) {
995
      case DS_BLOCK_TEMPLATE:
996
        $block->region = NULL;
997
        $block->module = $module;
998
        $block->delta = $delta;
999
        $elements = array('elements' => array('#block' => $block, '#children' => $block->content));
1000
        // Add contextual links.
1001
        if ($contextual) {
1002
          $elements['elements'] += array('#contextual_links' => array_merge($contextual_links, array('block' => array('admin/structure/block/manage', array($block->module, $block->delta)))));
1003
        }
1004
        return theme('block', $elements);
1005
        break;
1006
      case DS_BLOCK_TITLE_CONTENT:
1007
        return '<h2 class="block-title">' . $block->subject . '</h2>' . $block->content;
1008
        break;
1009
      case DS_BLOCK_CONTENT:
1010
        return $block->content;
1011
        break;
1012
    }
1013 971
  }
1014 972
}
1015 973

  

Formats disponibles : Unified diff