Projet

Général

Profil

Révision 4543c6c7

Ajouté par Assos Assos il y a plus de 10 ans

Weekly update of contrib modules

Voir les différences:

htmltest/sites/all/modules/addthis/includes/addthis.block.inc
24 24
 * want to change this specific display.
25 25
 */
26 26
function addthis_block_view($block_name = '') {
27

  
27 28
  if ($block_name == AddThis::BLOCK_NAME) {
29

  
28 30
    $widget_type = AddThis::getInstance()->getBlockDisplayType();
29
    $markup = AddThis::getInstance()->getDisplayMarkup($widget_type, array('#block' => AddThis::BLOCK_NAME));
31
    $widget_settings = AddThis::getInstance()->getBlockDisplaySettings();
32

  
33
    $block_options = array(
34
      '#block' => AddThis::BLOCK_NAME,
35
      '#display' => array(
36
        'settings' => $widget_settings,
37
      )
38
    );
39

  
40
    $markup = AddThis::getInstance()->getDisplayMarkup($widget_type, $block_options);
30 41
    return array(
31 42
      'subject' => '',
32 43
      'content' => $markup,
......
38 49
 * Implements hook_block_configure().
39 50
 */
40 51
function addthis_block_configure($delta = '') {
41
  $form[AddThis::BLOCK_WIDGET_TYPE_KEY] = array(
42
    '#type' => 'select',
43
    '#title' => t('AddThis display type'),
44
    '#options' => AddThis::getInstance()->getDisplayTypes(),
45
    '#default_value' => AddThis::getInstance()->getBlockDisplayType(),
46
  );
47
  return $form;
52
  AddThis::getInstance()->includeWidgetJs();
53

  
54
  return array();
48 55
}
49 56

  
50 57
/**
51 58
 * Implements hook_block_save().
52 59
 */
53 60
function addthis_block_save($delta = '', $edit = array()) {
54
  variable_set(AddThis::BLOCK_WIDGET_TYPE_KEY, $edit[AddThis::BLOCK_WIDGET_TYPE_KEY]);
61
  variable_set(AddThis::BLOCK_WIDGET_TYPE_KEY, $edit['addthis_settings']['type']);
62
  variable_set(AddThis::BLOCK_WIDGET_SETTINGS_KEY, $edit['addthis_settings']['settings']);
63
}
64

  
65
/**
66
 * Callback submit.
67
 */
68
function _addthis_settings_form_block_submit($form, &$form_state) {
69
  $form_state['rebuild'] = TRUE;
70
}
71

  
72
/**
73
 * Callback to return ajax replace part.
74
 */
75
function _addthis_settings_form_block_submit_callback($form, &$form_state) {
76
  return $form['settings']['addthis_settings']['form'];
77
}
78

  
79
/**
80
 * Implements hook_form_FORM_ID_alter().
81
 */
82
function addthis_form_block_admin_configure_alter(&$form, &$form_state) {
83

  
84
  if ($form['module']['#value'] == 'addthis' && $form['delta']['#value'] == 'addthis_block') {
85
    form_load_include($form_state, 'inc', 'addthis', 'addthis.block');
86
    $form['#cache'] = TRUE;
87

  
88
    $form['settings']['addthis_settings'] = array(
89
      '#type' => 'fieldset',
90
      '#title' => 'Display settings',
91
    );
92

  
93
    // Retrieve settings.
94
    $addthis_settings['type'] = AddThis::getInstance()->getBlockDisplayType();
95
    $addthis_settings['settings'] = AddThis::getInstance()->getBlockDisplaySettings();
96

  
97
    // Create a addthis settings form based on the available configuration.
98
    $element = _addthis_settings_form(
99
      isset($form['addthis_settings']['form']) ? $form['addthis_settings']['form'] : array(),
100
      $form_state,
101
      isset($addthis_settings['type']) ? $addthis_settings['type'] : NULL,
102
      isset($addthis_settings['settings']) ? $addthis_settings['settings'] : NULL
103
    );
104

  
105
    // Change the submit and callback because our handling is different and the
106
    // form structure is different form the default implementation.
107
    $element['type']['#submit'] = array('_addthis_settings_form_block_submit');
108
    $element['type']['#ajax']['callback'] = '_addthis_settings_form_block_submit_callback';
109
    $form['settings']['addthis_settings']['form'] = $element;
110

  
111
    array_unshift($form['#submit'], '_addthis_settings_form_block_submit');
112
  }
113

  
114
  return $form;
55 115
}

Formats disponibles : Unified diff