Skip to content

Commit

Permalink
Issue backdrop-contrib#9: Remove legacy block help and unneeded setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jen Lampton committed Dec 24, 2016
1 parent ffcb414 commit eb229a1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 51 deletions.
5 changes: 1 addition & 4 deletions sharethis.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,14 @@ function sharethis_configuration_form($form, &$form_state) {
'#type' => 'radios',
'#options' => array(
'content' => t('Node content'),
'block' => t('Block'),
'links' => t('Links area'),
),
'#default_value' => config_get('sharethis.settings', 'sharethis_location'),
);

// Add an information section for each location type, each dependent on the
// currently selected location.
foreach (array('links', 'content', 'block') as $location_type) {
foreach (array('links', 'content') as $location_type) {
$form['context'][$location_type]['#type'] = 'container';
$form['context'][$location_type]['#states']['visible'][':input[name="sharethis_location"]'] = array('value' => $location_type);
}
Expand All @@ -123,8 +122,6 @@ function sharethis_configuration_form($form, &$form_state) {
'#prefix' => '<em>',
'#suffix' => '</em>',
);
// Add help text for the 'block' location.
$form['context']['block']['#children'] = t('You must choose which region to display the <em>ShareThis block</em> in from the <a href="@blocksadmin">Blocks administration</a>.', array('@blocksadmin' => url('admin/structure/block')));

// Add checkboxes for each view mode of each bundle.
$entity_info = entity_get_info('node');
Expand Down
92 changes: 45 additions & 47 deletions sharethis.module
Original file line number Diff line number Diff line change
Expand Up @@ -192,62 +192,60 @@ function sharethis_block_view($delta='') {
function sharethis_block_contents() {
$output ='';

if (config_get('sharethis.settings', 'sharethis_location') == 'block') {
// First get all of the options for the sharethis widget from the database:
$data_options = sharethis_get_options_array();
// 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'] : '<front>';
if ($path == config_get('system.core', 'site_frontpage')) {
$path = "<front>";
}
$absolute_path = url($path, array('absolute' => TRUE));
$page_title = decode_entities(backdrop_get_title());
$path = isset($_GET['q']) ? $_GET['q'] : '<front>';
if ($path == config_get('system.core', 'site_frontpage')) {
$path = "<front>";
}
$absolute_path = url($path, array('absolute' => TRUE));
$page_title = decode_entities(backdrop_get_title());

// Inject the extra services.
foreach ($data_options['option_extras'] as $service) {
$data_options['services'] .= ',"' . $service . '"';
}
// Inject the extra services.
foreach ($data_options['option_extras'] as $service) {
$data_options['services'] .= ',"' . $service . '"';
}

// The share buttons are simply spans of the form class='st_SERVICE_BUTTONTYPE' -- "st" stands for ShareThis.
$type = backdrop_substr($data_options['buttons'], 4);
$type = $type == "_" ? "" : check_plain($type);
$service_array = explode(",", $data_options['services']);
$output = "<div class='sharethis-buttons'><div class='sharethis-wrapper'>";
foreach ($service_array as $service_full) {
// Strip the quotes from the element in the array (They are there for javascript)
$service = explode(":", $service_full);
// Service names are expected to be parsed by Name:machine_name. If only one
// element in the array is given, it's an invalid service.
if (count($service) < 2) {
continue;
}
// The share buttons are simply spans of the form class='st_SERVICE_BUTTONTYPE' -- "st" stands for ShareThis.
$type = backdrop_substr($data_options['buttons'], 4);
$type = $type == "_" ? "" : check_plain($type);
$service_array = explode(",", $data_options['services']);
$output = "<div class='sharethis-buttons'><div class='sharethis-wrapper'>";
foreach ($service_array as $service_full) {
// Strip the quotes from the element in the array (They are there for javascript)
$service = explode(":", $service_full);
// Service names are expected to be parsed by Name:machine_name. If only one
// element in the array is given, it's an invalid service.
if (count($service) < 2) {
continue;
}

// Find the service code name.
$service_code_name = backdrop_substr($service[1], 0, -1);
// Switch the title on a per-service basis if required.
$title = $page_title;
switch ($service_code_name) {
case 'twitter':
$title = empty($data_options['twitter_suffix']) ? $title : check_plain($title) . ' ' . check_plain($data_options['twitter_suffix']);
break;
}
// Find the service code name.
$service_code_name = backdrop_substr($service[1], 0, -1);
// Switch the title on a per-service basis if required.
$title = $page_title;
switch ($service_code_name) {
case 'twitter':
$title = empty($data_options['twitter_suffix']) ? $title : check_plain($title) . ' ' . check_plain($data_options['twitter_suffix']);
break;
}

// Sanitize the service code for display.
$display = check_plain($service_code_name);
// Sanitize the service code for display.
$display = check_plain($service_code_name);

// Put together the span attributes.
$output .='<span st_url="' . $absolute_path . '" st_title="' . $title . '" class="st_' . $display . $type . '"';
if ($service_code_name == 'twitter') {
if (!empty($data_options['twitter_handle'])) {
$output .='<span st_via="' . $data_options['twitter_handle'] . '" st_username="' . $data_options['twitter_recommends'] . '"';
}
// Put together the span attributes.
$output .='<span st_url="' . $absolute_path . '" st_title="' . $title . '" class="st_' . $display . $type . '"';
if ($service_code_name == 'twitter') {
if (!empty($data_options['twitter_handle'])) {
$output .='<span st_via="' . $data_options['twitter_handle'] . '" st_username="' . $data_options['twitter_recommends'] . '"';
}
$output .='</span>';
}
$output .='</div></div>';

sharethis_include_js();
$output .='</span>';
}
$output .='</div></div>';

sharethis_include_js();

return $output;
}
Expand Down

0 comments on commit eb229a1

Please sign in to comment.