'addthis', ); return $hooks; } /** * Implements hook_help(). */ function addthis_help($path, $arg) { switch ($path) { case 'admin/help#addthis': $output = '

' . t('About') . '

'; $output .= '

'; $output .= t('The AddThis module defines AddThis field type for the Field module. A AddThis field may contain a button, toolbox, sharecount or customized sharing tool using AddThis.com.'); $output .= '

'; return $output; } } /** * Implements hook_filter_format_update(). */ function addthis_filter_format_update($format) { field_cache_clear(); } /** * Implements hook_filter_format_disable(). */ function addthis_filter_format_disable($format) { field_cache_clear(); } /** * Implements hook_menu(). */ function addthis_menu() { $menu_items['admin/config/user-interface/addthis'] = array( 'title' => 'AddThis', 'description' => 'Configure AddThis settings.', 'page callback' => 'drupal_get_form', 'page arguments' => array('addthis_admin_settings_form'), 'access arguments' => array(AddThis::PERMISSION_ADMINISTER_ADDTHIS), 'type' => MENU_NORMAL_ITEM, 'file' => AddThis::ADMIN_INCLUDE_FILE, ); return $menu_items; } /** * Implements hook_permission(). */ function addthis_permission() { return array( AddThis::PERMISSION_ADMINISTER_ADDTHIS => array( 'title' => t('Administer AddThis'), 'description' => t('Perform maintenance tasks for AddThis.'), ), AddThis::PERMISSION_ADMINISTER_ADVANCED_ADDTHIS => array( 'title' => t('Administer advanced AddThis'), 'description' => t('Perform advanced maintenance tasks for AddThis.'), ), ); } /** * Implements hook_page_alter(). */ function addthis_page_alter(&$page) { AddThis::getInstance()->addWidgetJs(); AddThis::getInstance()->addConfigurationOptionsJs(); } /** * Implements hook_form_FORM_ID_alter(). * * Hide the instance fieldset because there aren't any values per instance. */ function addthis_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) { if ($form['#field']['type'] == AddThis::FIELD_TYPE && $form['#field']['type'] == AddThis::MODULE_NAME) { $form['field']['#access'] = FALSE; $form['instance']['required']['#access'] = FALSE; $form['instance']['description']['#access'] = FALSE; $form['instance']['default_value_widget']['#access'] = FALSE; } } /** * Implements hook_rdf_namespaces() */ function addthis_rdf_namespaces() { if (AddThis::getInstance()->isFacebookLikeCountSupportEnabled()) { return array( 'fb' => 'http://www.facebook.com/2008/fbml', ); } return array(); } /** * Implements hook_theme(). */ function addthis_theme($existing, $type, $theme, $path) { return array( 'addthis_wrapper' => array( 'render element' => 'addthis_wrapper', ), 'addthis_element' => array( 'render element' => 'addthis_element', ), 'addthis' => array( 'render element' => 'addthis', ), ); } /** * Implements hook_preprocess() for theme_addthis. */ function template_preprocess_addthis(&$variables) { if (isset($variables[0]) && count($variables) == 3) { $variables['#display'] = $variables[0]; unset($variables[0]); } } function theme_addthis($variables) { $markup = AddThis::getInstance()->getDisplayMarkup($variables['#display']); return render($markup); } function theme_addthis_wrapper($variables) { $element = $variables['addthis_wrapper']; $output = '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . '>'; $children = element_children($element); if (count($children) > 0) { foreach ($children as $child) { $output .= render($element[$child]); } } $output .= '\n"; return $output; } /** * Theme the elements that are created in the AddThis module. This is * created with hook_addthis_element. */ function theme_addthis_element($variables) { $element = $variables['addthis_element']; if (!isset($element['#value'])) { return '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . " />\n"; } $output = '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . '>'; if (isset($element['#value_prefix'])) { $output .= $element['#value_prefix']; } $output .= $element['#value']; if (isset($element['#value_suffix'])) { $output .= $element['#value_suffix']; } $output .= '\n"; return $output; }