You are here

private function ShareMessage::build_services_part in Share Message 7

Function that adds services as part of addThis widget.

1 call to ShareMessage::build_services_part()
ShareMessage::buildContent in includes/sharemessage.entity.inc
Overrides Entity::buildContent().

File

includes/sharemessage.entity.inc, line 305
Definition of ShareMessage entity class.

Class

ShareMessage

Code

private function build_services_part($context) {
  $services = !empty($this->settings['services']) ? $this->settings['services'] : variable_get('sharemessage_default_services', array());

  // Get some additional namespaced button attributes.
  $namespace_attributes = $this
    ->getNameSpaceAttributes($this
    ->getIconStyle());

  // Configured.
  $services_HTML = '';
  if (!empty($services)) {
    foreach ($services as $key => $service) {
      if ($key == 'twitter' && field_get_items('sharemessage', $this, 'sharemessage_short')) {

        // @todo. This doesn't work, should be printed here.
        drupal_add_js("var addthis_share = { templates: { twitter: '" . str_replace("'", "\\'", $this
          ->getTokenizedField('sharemessage_short', $context, '')) . "', } }", array(
          'type' => 'inline',
        ));
      }
      $namespace_attribute = !empty($namespace_attributes[$key]) ? $namespace_attributes[$key] : '';
      $services_HTML .= '<a class="addthis_button_' . $key . '" ' . $namespace_attribute . '></a>';
    }
  }
  else {

    // Default.
    $services_HTML .= '
        <a class="addthis_button_preferred_1"></a>
        <a class="addthis_button_preferred_2"></a>
        <a class="addthis_button_preferred_3"></a>
        <a class="addthis_button_preferred_4"></a>
        <a class="addthis_button_preferred_5"></a>';
  }
  return $services_HTML;
}