Permalink
Browse files

added site global share buttons block and made it configurable the sa…

…me way as noticeme fields
  • Loading branch information...
1 parent d0396a0 commit 81b67e75e4c405d8f436ccf46e0d83a34c7fb231 @dawitti dawitti committed Mar 13, 2012
Showing with 142 additions and 14 deletions.
  1. +3 −3 README.markdown
  2. +1 −1 noticeme.field.inc
  3. +10 −10 noticeme.forms.inc
  4. +105 −0 noticeme.module
  5. +23 −0 noticeme.theme.inc
View
@@ -16,9 +16,9 @@ TODOS:
js/noticeme.js [DONE]
js/noticeme_forms.js [DONE]
-- globale bilddatei
-- globaler like-button block (aktuelle seite oder gesamte seite?)
-- vertical tabs rausnehmen
+- globale bilddatei [DONE]
+- globaler like-button block [DONE]
+- vertical tabs rausnehmen [DONE]
- clean uninstall
- integrität bei mehreren instances prüfen
- alle möglichkeiten testen
View
@@ -61,7 +61,7 @@ function _noticeme_field_formatter_settings_validate($element, &$form_state, $fo
// in noticeme_field_formatter_view().
foreach ($values as $network => $settings) {
foreach ($settings as $key => $value) {
- $values[$network . '_' . $key] = $value;
+ $values[$key] = $value;
}
}
}
View
@@ -55,7 +55,7 @@ function _noticeme_configuration_form($values) {
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
- 'display' => array(
+ 'facebook_display' => array(
'#title' => t('Display'),
'#type' => 'select',
'#options' => array(
@@ -66,17 +66,17 @@ function _noticeme_configuration_form($values) {
),
'#default_value' => $values['facebook_display'],
),
- 'send' => array(
+ 'facebook_send' => array(
'#type' => 'checkbox',
'#title' => t('Show send button'),
'#default_value' => $values['facebook_send'],
),
- 'faces' => array(
+ 'facebook_faces' => array(
'#type' => 'checkbox',
'#title' => t('Show faces'),
'#default_value' => $values['facebook_faces'],
),
- 'verb' => array(
+ 'facebook_verb' => array(
'#type' => 'select',
'#title' => t('Verb'),
'#options' => array(
@@ -85,7 +85,7 @@ function _noticeme_configuration_form($values) {
),
'#default_value' => $values['facebook_verb'],
),
- 'color' => array(
+ 'facebook_color' => array(
'#type' => 'select',
'#title' => t('Color'),
'#options' => array(
@@ -94,7 +94,7 @@ function _noticeme_configuration_form($values) {
),
'#default_value' => $values['facebook_color'],
),
- 'font' => array(
+ 'facebook_font' => array(
'#type' => 'select',
'#title' => t('Font'),
'#options' => array(
@@ -113,7 +113,7 @@ function _noticeme_configuration_form($values) {
'#title' => t('Google +1'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
- 'display' => array(
+ 'google_display' => array(
'#title' => t('Display'),
'#type' => 'select',
'#options' => array(
@@ -125,7 +125,7 @@ function _noticeme_configuration_form($values) {
),
'#default_value' => $values['google_display'],
),
- 'annotation' => array(
+ 'google_annotation' => array(
'#title' => t('Annotation'),
'#type' => 'select',
'#options' => array(
@@ -142,7 +142,7 @@ function _noticeme_configuration_form($values) {
'#title' => t('Tweet this'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
- 'display' => array(
+ 'twitter_display' => array(
'#type' => 'select',
'#title' => t('Display'),
'#options' => array(
@@ -152,7 +152,7 @@ function _noticeme_configuration_form($values) {
),
'#default_value' => $values['twitter_display'],
),
- 'display_count' => array(
+ 'twitter_display_count' => array(
'#type' => 'checkbox',
'#title' => t('Display count'),
'#default_value' => $values['twitter_display_count'],
View
@@ -82,10 +82,91 @@ function noticeme_menu() {
}
/**
+ * Implements hook_block_info().
+ */
+function noticeme_block_info() {
+ return array(
+ 'noticeme_global' => array(
+ 'info' => t('Sitewide Noticeme Share Buttons'),
+ 'cache' => DRUPAL_CACHE_GLOBAL,
+ ''
+ ),
+ );
+}
+
+/**
+ * Implements hook_block_view().
+ */
+function noticeme_block_view($delta = '') {
+ switch($delta) {
+ case 'noticeme_global':
+ return array(
+ 'subject' => NULL,
+ 'content' => noticeme_global_block(),
+ );
+ default:
+ }
+}
+
+/**
+ * Implements hook_block_configure().
+ */
+function noticeme_block_configure($delta = '') {
+ switch($delta) {
+ case 'noticeme_global':
+ $values = array(
+ 'facebook_display' => variable_get('noticeme_global_block_fb_display', 'standard'),
+ 'facebook_send' => variable_get('noticeme_global_block_fb_send', 'false'),
+ 'facebook_faces' => variable_get('noticeme_global_block_fb_faces', 'false'),
+ 'facebook_verb' => variable_get('noticeme_global_block_fb_verb', 'like'),
+ 'facebook_color' => variable_get('noticeme_global_block_fb_color', 'light'),
+ 'facebook_font' => variable_get('noticeme_global_block_fb_font', 'Arial'),
+ 'google_display' => variable_get('noticeme_global_block_google_display', 'standard'),
+ 'google_annotation' => variable_get('noticeme_global_block_google_annotation', 'info'),
+ 'twitter_display' => variable_get('noticeme_global_block_twitter_display', 'small'),
+ 'twitter_display_count' => variable_get('noticeme_global_block_twitter_display_count', 'false'),
+ );
+ return _noticeme_configuration_form($values);
+ default:
+ }
+}
+
+/**
+ * Implements hook_block_save().
+ */
+function noticeme_block_save($delta = '', $edit = array()) {
+ switch($delta) {
+ case 'noticeme_global':
+ $values = array(
+ variable_set('noticeme_global_block_fb_display', $edit['facebook_display']),
+ variable_set('noticeme_global_block_fb_send', $edit['facebook_send']),
+ variable_set('noticeme_global_block_fb_faces', $edit['facebook_faces']),
+ variable_set('noticeme_global_block_fb_verb', $edit['facebook_verb']),
+ variable_set('noticeme_global_block_fb_color', $edit['facebook_color']),
+ variable_set('noticeme_global_block_fb_font', $edit['facebook_font']),
+ variable_set('noticeme_global_block_google_display', $edit['google_display']),
+ variable_set('noticeme_global_block_google_annotation', $edit['google_annotation']),
+ variable_set('noticeme_global_block_twitter_display', $edit['twitter_display']),
+ variable_set('noticeme_global_block_twitter_display_count', $edit['twitter_display_count']),
+ );
+ default:
+ }
+}
+
+/**
* Implements hook_theme().
*/
function noticeme_theme() {
return array(
+ // Theme global share buttons block.
+ 'global_share_buttons_block' => array(
+ 'variables' => array(
+ 'facebook_like' => FALSE,
+ 'twitter_tweet' => FALSE,
+ 'google_plus_one' => FALSE,
+ ),
+ 'file' => 'noticeme.theme.inc',
+ ),
// Theme facebook like button.
'facebook_like' => array(
'variables' => array(
@@ -387,3 +468,27 @@ function _noticeme_field_ids() {
}
return $ids;
}
+
+/**
+ * Content for the sitewide share buttons block.
+ */
+function noticeme_global_block() {
+ global $base_url;
+ $url = url($base_url, array('absolute' => TRUE));
+ $variables = array(
+ 'facebook_like' => array(
+ 'url' => $url,
+ 'layout' => 'button_count',
+ 'send' => 'false',
+ 'show-faces' => 'false',
+ 'action' => 'like',
+ ),
+ 'google_plus_one' => array(
+ 'url' => $url,
+ ),
+ 'twitter_tweet' => array(
+ 'url' => $url,
+ ),
+ );
+ return theme('global_share_buttons_block', $variables);
+}
View
@@ -5,6 +5,29 @@
*/
/**
+ * Theme the global share buttons block.
+ */
+function theme_global_share_buttons_block($variables) {
+ $element = array();
+ if($variables['facebook_like']) {
+ $element['facebook_like'] = array(
+ '#markup' => theme('facebook_like',$variables['facebook_like']),
+ );
+ }
+ if($variables['google_plus_one']) {
+ $element['google_plus_one'] = array(
+ '#markup' => theme('google_plus',$variables['google_plus_one']),
+ );
+ }
+ if($variables['twitter_tweet']) {
+ $element['twitter_tweet'] = array(
+ '#markup' => theme('twitter_tweet',$variables['twitter_tweet']),
+ );
+ }
+ return render($element);
+}
+
+/**
* Theme a facebook like button.
*/
function theme_facebook_like($variables) {

0 comments on commit 81b67e7

Please sign in to comment.