diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..8a31c3eb0ea013c102548bb4ebf241c92afb68a6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.buildpath +.project +.settings/* + diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1faa7c6e74e5411615f8cb9b154cc63ad9c7601e..744cf633cf26e9871d7595a8861373429779c1a6 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1 +1,2 @@ -Fix for #1308970 reported by vasike,fixed by matglas86. Error in block configure. \ No newline at end of file +Fix for #1308970 reported by vasike,fixed by matglas86. Error in block configure. +Changed dir name for submodule from addthis_display to addthis_displays. diff --git a/addthis.addthis.inc b/addthis.addthis.inc index 248051a7bcee0fc3af159910710838b6536626a4..1dd5b8395d7daae60410b4e71bafd94ee90e7f13 100644 --- a/addthis.addthis.inc +++ b/addthis.addthis.inc @@ -1,7 +1,7 @@ getAddThisAttributesMarkup($entity); + $element['#attributes'] += $addthis->getAddThisAttributesMarkup($variables); // Here we start the children of the a element. $image = array( @@ -55,7 +54,6 @@ function addthis_addthis_display_markup__addthis_large_button($variables = NULL) */ function addthis_addthis_display_markup__addthis_compact_button($variables = NULL) { $addthis = AddThis::getInstance(); - $entity = $variables['#entity']; // Create wrapper element a $element = array( @@ -68,7 +66,7 @@ function addthis_addthis_display_markup__addthis_compact_button($variables = NUL ) ) ); - $element['#attributes'] += $addthis->getAddThisAttributesMarkup($entity); + $element['#attributes'] += $addthis->getAddThisAttributesMarkup($variables); // Create img button $image = array( @@ -92,7 +90,6 @@ function addthis_addthis_display_markup__addthis_compact_button($variables = NUL */ function addthis_addthis_display_markup__addthis_toolbox($variables = NULL) { $addthis = AddThis::getInstance(); - $entity = $variables['#entity']; // Creating render array for the widget. $element = array( @@ -108,7 +105,7 @@ function addthis_addthis_display_markup__addthis_toolbox($variables = NULL) { ) ), ); - $element['#attributes'] += $addthis->getAddThisAttributesMarkup($entity); + $element['#attributes'] += $addthis->getAddThisAttributesMarkup($variables); // All service elements $items = array(); @@ -150,7 +147,6 @@ function addthis_addthis_display_markup__addthis_toolbox($variables = NULL) { */ function addthis_addthis_display_markup__addthis_sharecount($variables = NULL) { $addthis = AddThis::getInstance(); - $entity = $variables['#entity']; $element = array( '#theme' => 'addthis_wrapper', @@ -173,7 +169,7 @@ function addthis_addthis_display_markup__addthis_sharecount($variables = NULL) { ), ), ); - $item['#attributes'] += $addthis->getAddThisAttributesMarkup($entity); + $item['#attributes'] += $addthis->getAddThisAttributesMarkup($variables); $element[] = $item; return $element; diff --git a/classes/AddThis.php b/classes/AddThis.php index 7bae2fa0e1104ecc70af1b21814d1c9dee6e1306..96d039351c6a4af571420ebf71b9794f9a7a0a90 100644 --- a/classes/AddThis.php +++ b/classes/AddThis.php @@ -20,6 +20,7 @@ class AddThis { // AddThis attribute and parameter names (as defined in AddThis APIs) const PROFILE_ID_QUERY_PARAMETER = 'pubid'; const TITLE_ATTRIBUTE = 'addthis:title'; + const URL_ATTRIBUTE = 'addthis:title'; // Persistent variable keys const ADDRESSBOOK_ENABLED_KEY = 'addthis_addressbook_enabled'; @@ -65,7 +66,7 @@ class AddThis { const WIDGET_TYPE_LARGE_BUTTON = 'addthis_large_button'; const WIDGET_TYPE_SHARECOUNT = 'addthis_sharecount'; const WIDGET_TYPE_TOOLBOX = 'addthis_toolbox'; - + // Styles const CSS_32x32 = 'addthis_32x32_style'; @@ -120,7 +121,7 @@ class AddThis { // When we have the entity and entity_type we can send it to the url. if (isset($options['#entity']) && isset($options['#entity_type'])) { - // See if we can create the url and send it through a hook so others + // See if we can create the url and send it through a hook so others // can play with it. $uri = entity_uri($options['#entity_type'], $options['#entity']); $uri['options'] += array( @@ -129,7 +130,7 @@ class AddThis { // Add hook here to alter the uri maybe also based on fields from the // entity. Like a custom share link. Pass $options and $uri. Return // a uri object to which we can reset it. Maybe use the alter structure. - + $options['#url'] = url($uri['path'], $uri['options']); } @@ -359,12 +360,22 @@ class AddThis { return (boolean) variable_get(self::ADDRESSBOOK_ENABLED_KEY, FALSE); } - public function getAddThisAttributesMarkup($entity) { - if (is_object($entity)) { + /** + * Define the following object in the $optoins. + * + * #entity_type + * #entity + * #url + */ + public function getAddThisAttributesMarkup($options) { + if (isset($options)) { $attributes = array(); // Add title - $attributes += $this->getAddThisTitleAttributeMarkup($entity); + if (isset($options['#entity'])) { + $attributes += $this->getAttributeTitle($options['#entity']); + } + $attributes += $this->getAttributeUrl($options); // Return the array with attributes return $attributes; @@ -372,10 +383,22 @@ class AddThis { return array(); } - private function getAddThisTitleAttributeMarkup($entity) { - return array( - self::TITLE_ATTRIBUTE => (check_plain($entity->title) . ' - ' . variable_get('site_name')) - ); + private function getAttributeTitle($entity) { + if (isset($entity->title)) { + return array( + self::TITLE_ATTRIBUTE => (check_plain($entity->title) . ' - ' . variable_get('site_name')) + ); + } + return array(); + } + + private function getAttributeUrl($options) { + if (isset($options['#url'])) { + return array( + self::URL_ATTRIBUTE => $options['#url'] + ); + } + return array(); } public function getLargeButtonsClass() {