diff --git a/sharethis.module b/sharethis.module index 647cdb5..1aa3d75 100644 --- a/sharethis.module +++ b/sharethis.module @@ -63,6 +63,15 @@ function sharethis_permission() { * This is the main configuration form for the admin page. */ function sharethis_configuration_form($form, &$form_state) { +  + // The sharethis_location variable may have been stored as a string,  + // so turn it to an array if needed. + $location = variable_get('sharethis_location', 'content'); + if(! is_array($location)) { + $location = array($location); + variable_set('sharethis_location', $location); + } +  // First, setup variables we will need. // Get the path variables setup. $my_path = drupal_get_path('module', 'sharethis'); @@ -156,7 +165,7 @@ function sharethis_configuration_form($form, &$form_state) {  $form['context']['sharethis_location'] = array( '#title' => t('Location'), - '#type' => 'radios', + '#type' => 'checkboxes', '#options' => array( 'content' => t('Node content'), 'block' => t('Block'), @@ -402,9 +411,8 @@ function sharethis_node_view($node, $view_mode, $langcode) { $mPath = url('node/' . $node->nid, array('absolute' => TRUE)); $mTitle = $node->title;  - // Check where we want to display the ShareThis widget. - switch (variable_get('sharethis_location', 'content')) { - case 'content': + $location = variable_get('sharethis_location', array('content')); + if(in_array('content', $location) && $location['content'] === 'content') { $enabled_types = $data_options['sharethis_node_types']; if (isset($enabled_types[$node->type]) && $enabled_types[$node->type] === $node->type) { $node->content['sharethis'] = array( @@ -414,9 +422,9 @@ function sharethis_node_view($node, $view_mode, $langcode) { '#value' => theme('sharethis', array('data_options' => $data_options, 'm_path' => $mPath, 'm_title' => $mTitle)), '#weight' => intval(variable_get('sharethis_weight', 10)), ); - } - break; - case 'links': + } + } + if(in_array('links', $location) && $location['links'] === 'links') { $enabled_view_modes = variable_get('sharethis_' . $node->type . '_options', array()); if (isset($enabled_view_modes[$view_mode]) && $enabled_view_modes[$view_mode]) { $links['sharethis'] = array( @@ -435,7 +443,6 @@ function sharethis_node_view($node, $view_mode, $langcode) { '#weight' => intval(variable_get('sharethis_weight', 10)), ); } - break; } }  @@ -445,7 +452,8 @@ function sharethis_node_view($node, $view_mode, $langcode) { function sharethis_field_extra_fields() { $extra = array(); // Only add extra fields if the location is the node content. - if (variable_get('sharethis_location', 'content') == 'content') { + $location = variable_get('sharethis_location', array('content'));  + if (in_array('content', $location) && $location['content'] === 'content') {  $entity_info = entity_get_info('node'); foreach ($entity_info['bundles'] as $bundle => $bundle_info) { $extra['node'][$bundle]['display'] = array( @@ -676,7 +684,8 @@ function sharethis_block_view($delta='') { * @return string */ function sharethis_block_contents() { - if (variable_get('sharethis_location', 'content') == 'block') { + $location = variable_get('sharethis_location', array('content')); + if(in_array('block', $location) && $location['block'] === 'block') { // First get all of the options for the sharethis widget from the database: $data_options = sharethis_get_options_array(); $path = isset($_GET['q']) ? $_GET['q'] : '';