1 |
85ad3d82
|
Assos Assos
|
<?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 |
2c8c2b87
|
Assos Assos
|
// Add the widget script.
|
36 |
|
|
$script_manager = AddThisScriptManager::getInstance();
|
37 |
|
|
$script_manager->attachJsToElement($element);
|
38 |
|
|
|
39 |
85ad3d82
|
Assos Assos
|
$services = trim($options['#display']['settings']['share_services']);
|
40 |
|
|
$services = str_replace(' ', '', $services);
|
41 |
|
|
$services = explode(',', $services);
|
42 |
|
|
|
43 |
|
|
// All service elements
|
44 |
|
|
$items = array();
|
45 |
|
|
foreach ($services as $service) {
|
46 |
|
|
$items[$service] = array(
|
47 |
|
|
'#theme' => 'addthis_element',
|
48 |
|
|
'#tag' => 'a',
|
49 |
|
|
'#value' => '',
|
50 |
|
|
'#attributes' => array(
|
51 |
|
|
'href' => $addthis->getBaseBookmarkUrl(),
|
52 |
|
|
'class' => array(
|
53 |
|
|
'addthis_button_' . $service,
|
54 |
|
|
),
|
55 |
|
|
),
|
56 |
|
|
'#addthis_service' => $service,
|
57 |
|
|
);
|
58 |
|
|
|
59 |
2c8c2b87
|
Assos Assos
|
// Add individual counters.
|
60 |
|
|
if (strpos($service, 'counter_') === 0) {
|
61 |
|
|
$items[$service]['#attributes']['class'] = array("addthis_$service");
|
62 |
|
|
}
|
63 |
|
|
|
64 |
85ad3d82
|
Assos Assos
|
// Basic implementations of bubble counter orientation.
|
65 |
|
|
// @todo Figure all the bubbles out and add them.
|
66 |
2c8c2b87
|
Assos Assos
|
// Still missing: tweetme, hyves and stubleupon, google_plusone_badge.
|
67 |
85ad3d82
|
Assos Assos
|
//
|
68 |
|
|
$orientation = ($options['#display']['settings']['counter_orientation'] == 'horizontal' ? TRUE : FALSE);
|
69 |
|
|
switch ($service) {
|
70 |
2c8c2b87
|
Assos Assos
|
case 'linkedin_counter':
|
71 |
|
|
$items[$service]['#attributes'] += array(
|
72 |
|
|
'li:counter' => ($orientation ? '' : 'top'),
|
73 |
|
|
);
|
74 |
|
|
break;
|
75 |
85ad3d82
|
Assos Assos
|
case 'facebook_like':
|
76 |
|
|
$items[$service]['#attributes'] += array(
|
77 |
|
|
'fb:like:layout' => ($orientation ? 'button_count' : 'box_count')
|
78 |
|
|
);
|
79 |
|
|
break;
|
80 |
2c8c2b87
|
Assos Assos
|
case 'facebook_share':
|
81 |
|
|
$items[$service]['#attributes'] += array(
|
82 |
|
|
'fb:share:layout' => ($orientation ? 'button_count' : 'box_count')
|
83 |
|
|
);
|
84 |
|
|
break;
|
85 |
85ad3d82
|
Assos Assos
|
case 'google_plusone':
|
86 |
|
|
$items[$service]['#attributes'] += array(
|
87 |
|
|
'g:plusone:size' => ($orientation ? 'standard' : 'tall')
|
88 |
|
|
);
|
89 |
|
|
break;
|
90 |
|
|
case 'tweet':
|
91 |
|
|
$items[$service]['#attributes'] += array(
|
92 |
|
|
'tw:count' => ($orientation ? 'horizontal' : 'vertical'),
|
93 |
|
|
'tw:via' => AddThis::getInstance()->getTwitterVia(),
|
94 |
|
|
);
|
95 |
|
|
break;
|
96 |
2c8c2b87
|
Assos Assos
|
case 'bubble_style':
|
97 |
|
|
$items[$service]['#attributes']['class'] = array(
|
98 |
|
|
'addthis_counter', 'addthis_bubble_style'
|
99 |
|
|
);
|
100 |
|
|
break;
|
101 |
|
|
case 'pill_style':
|
102 |
|
|
$items[$service]['#attributes']['class'] = array(
|
103 |
|
|
'addthis_counter', 'addthis_pill_style'
|
104 |
|
|
);
|
105 |
|
|
break;
|
106 |
85ad3d82
|
Assos Assos
|
}
|
107 |
|
|
}
|
108 |
|
|
$element += $items;
|
109 |
|
|
|
110 |
|
|
return $element;
|
111 |
|
|
}
|
112 |
|
|
|
113 |
|
|
/**
|
114 |
|
|
* Implements hook_addthis_display_markup__[display]().
|
115 |
|
|
*/
|
116 |
|
|
function addthis_displays_addthis_display_markup__addthis_basic_button($options = array()) {
|
117 |
|
|
|
118 |
4543c6c7
|
Assos Assos
|
$addthis = AddThis::getInstance();
|
119 |
c12e7e6a
|
Assos Assos
|
$settings = $options['#display']['settings'];
|
120 |
4543c6c7
|
Assos Assos
|
|
121 |
85ad3d82
|
Assos Assos
|
$button_img = 'http://s7.addthis.com/static/btn/sm-share-en.gif';
|
122 |
c12e7e6a
|
Assos Assos
|
if (isset($settings['buttons_size']) && $settings['buttons_size'] == 'big') {
|
123 |
85ad3d82
|
Assos Assos
|
$button_img = 'http://s7.addthis.com/static/btn/v2/lg-share-en.gif';
|
124 |
|
|
}
|
125 |
4543c6c7
|
Assos Assos
|
$button_img = $addthis->transformToSecureUrl($button_img);
|
126 |
85ad3d82
|
Assos Assos
|
|
127 |
c12e7e6a
|
Assos Assos
|
$extra_css = isset($settings['extra_css']) ? $settings['extra_css'] : '';
|
128 |
85ad3d82
|
Assos Assos
|
$element = array(
|
129 |
|
|
'#theme' => 'addthis_wrapper',
|
130 |
|
|
'#tag' => 'a',
|
131 |
|
|
'#attributes' => array(
|
132 |
|
|
'class' => array(
|
133 |
|
|
'addthis_button',
|
134 |
c12e7e6a
|
Assos Assos
|
$extra_css,
|
135 |
85ad3d82
|
Assos Assos
|
),
|
136 |
|
|
),
|
137 |
|
|
);
|
138 |
4543c6c7
|
Assos Assos
|
$element['#attributes'] += $addthis->getAddThisAttributesMarkup($options);
|
139 |
85ad3d82
|
Assos Assos
|
|
140 |
2c8c2b87
|
Assos Assos
|
// Add the widget script.
|
141 |
|
|
$script_manager = AddThisScriptManager::getInstance();
|
142 |
|
|
$script_manager->attachJsToElement($element);
|
143 |
|
|
|
144 |
c12e7e6a
|
Assos Assos
|
// Create img button.
|
145 |
85ad3d82
|
Assos Assos
|
$image = array(
|
146 |
|
|
'#theme' => 'addthis_element',
|
147 |
|
|
'#tag' => 'img',
|
148 |
|
|
'#attributes' => array(
|
149 |
|
|
'src' => $button_img,
|
150 |
|
|
'alt' => t('Share page with AddThis'),
|
151 |
|
|
),
|
152 |
|
|
);
|
153 |
|
|
$element[] = $image;
|
154 |
|
|
|
155 |
|
|
return $element;
|
156 |
|
|
} |