Projet

Général

Profil

Paste
Télécharger (3,61 ko) Statistiques
| Branche: | Révision:

root / htmltest / sites / all / modules / addthis / addthis_displays / addthis_displays.addthis.inc @ 4543c6c7

1
<?php
2

    
3
/**
4
 * @file
5
 * Implements AddThis markup functions.
6
 */
7

    
8
function addthis_displays_addthis_display_markup($display, $variables = NULL) {
9
  return NULL;
10
}
11

    
12
/**
13
 * Implements hook_addthis_display_markup__[display]().
14
 */
15
function addthis_displays_addthis_display_markup__addthis_basic_toolbox($options = array()) {
16
  $addthis = AddThis::getInstance();
17

    
18
  // Create a render array for the widget.
19
  $element = array(
20
    // Use #theme_wrappers to include the rendered children. Otherwise the
21
    // result is an empty element like <div></div>.
22
    '#theme' => 'addthis_wrapper',
23
    '#tag' => 'div',
24
    '#attributes' => array(
25
      'class' => array(
26
        'addthis_toolbox',
27
        'addthis_default_style',
28
        ($options['#display']['settings']['buttons_size'] == AddThis::CSS_32x32 ? AddThis::CSS_32x32 : NULL),
29
        $options['#display']['settings']['extra_css'],
30
      ),
31
    ),
32
  );
33
  $element['#attributes'] += $addthis->getAddThisAttributesMarkup($options);
34

    
35
  $services = trim($options['#display']['settings']['share_services']);
36
  $services = str_replace(' ', '', $services);
37
  $services = explode(',', $services);
38

    
39
  // All service elements
40
  $items = array();
41
  foreach ($services as $service) {
42
    $items[$service] = array(
43
      '#theme' => 'addthis_element',
44
      '#tag' => 'a',
45
      '#value' => '',
46
      '#attributes' => array(
47
        'href' => $addthis->getBaseBookmarkUrl(),
48
        'class' => array(
49
          'addthis_button_' . $service,
50
        ),
51
      ),
52
      '#addthis_service' => $service,
53
    );
54

    
55
    // Basic implementations of bubble counter orientation.
56
    // @todo Figure all the bubbles out and add them.
57
    //   Still missing: tweetme, hyves and stubleupon.
58
    //
59
    // @todo Fix a way to use addthis_bubble_style.
60
    //   There is a conflict now with using the class addthis_button_[service].
61
    //   You can't add this bubble style now.
62
    $orientation = ($options['#display']['settings']['counter_orientation'] == 'horizontal' ? TRUE : FALSE);
63
    switch ($service) {
64
      case 'facebook_like':
65
        $items[$service]['#attributes'] += array(
66
          'fb:like:layout' => ($orientation ? 'button_count' : 'box_count')
67
        );
68
        break;
69
      case 'google_plusone':
70
        $items[$service]['#attributes'] += array(
71
          'g:plusone:size' => ($orientation ? 'standard' : 'tall')
72
        );
73
        break;
74
      case 'tweet':
75
        $items[$service]['#attributes'] += array(
76
          'tw:count' => ($orientation ? 'horizontal' : 'vertical'),
77
          'tw:via' => AddThis::getInstance()->getTwitterVia(),
78
        );
79
        break;
80
    }
81
  }
82
  $element += $items;
83

    
84
  return $element;
85
}
86

    
87
/**
88
 * Implements hook_addthis_display_markup__[display]().
89
 */
90
function addthis_displays_addthis_display_markup__addthis_basic_button($options = array()) {
91

    
92
  $addthis = AddThis::getInstance();
93

    
94
  $button_img = 'http://s7.addthis.com/static/btn/sm-share-en.gif';
95
  if ($options['#display']['settings']['button_size'] == 'big') {
96
    $button_img = 'http://s7.addthis.com/static/btn/v2/lg-share-en.gif';
97
  }
98
  $button_img = $addthis->transformToSecureUrl($button_img);
99

    
100
  $element = array(
101
    '#theme' => 'addthis_wrapper',
102
    '#tag' => 'a',
103
    '#attributes' => array(
104
      'class' => array(
105
        'addthis_button',
106
        $options['#display']['settings']['extra_css'],
107
      ),
108
    ),
109
  );
110
  $element['#attributes'] += $addthis->getAddThisAttributesMarkup($options);
111

    
112
  // Create img button
113
  $image = array(
114
    '#theme' => 'addthis_element',
115
    '#tag' => 'img',
116
    '#attributes' => array(
117
      'src' => $button_img,
118
      'alt' => t('Share page with AddThis'),
119
    ),
120
  );
121
  $element[] = $image;
122

    
123
  return $element;
124
}