summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Glastra2011-11-08 14:27:34 (GMT)
committer Matthias Glastra2011-11-08 14:27:34 (GMT)
commite168be1d66dd26687f8e0a3358ceb514170c5f85 (patch)
treea4c8b30ad3a5ff3d6ea2d017d19107193de49994
parent8918fa80290b643d3033641e0ec2df7439d3e9dc (diff)
Fixes in markup processing.
-rw-r--r--.gitignore4
-rw-r--r--CHANGELOG.txt3
-rw-r--r--addthis.addthis.inc14
-rw-r--r--classes/AddThis.php43
4 files changed, 44 insertions, 20 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8a31c3e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+.buildpath
+.project
+.settings/*
+
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 1faa7c6..744cf63 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 248051a..1dd5b83 100644
--- a/addthis.addthis.inc
+++ b/addthis.addthis.inc
@@ -1,7 +1,7 @@
<?php
/**
* @file
- * This file contains the definitions for the AddThis Display types and the
+ * This file contains the definitions for the AddThis Display types and the
* rendering of markup.
*/
@@ -17,7 +17,6 @@ function addthis_addthis_display_markup($display, $variables = NULL) {
*/
function addthis_addthis_display_markup__addthis_large_button($variables = NULL) {
$addthis = AddThis::getInstance();
- $entity = $variables['#entity'];
// This is a render array representation.
$element = array(
@@ -31,7 +30,7 @@ function addthis_addthis_display_markup__addthis_large_button($variables = NULL)
)
)
);
- $element['#attributes'] += $addthis->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 7bae2fa..96d0393 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() {