View source
<?php
function fb_social_send_menu() {
$items = array();
$items['admin/settings/fb/social/send'] = array(
'type' => MENU_LOCAL_TASK,
'title' => 'send',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'fb_social_send_settings_form',
),
'file' => 'fb_social_send.admin.inc',
'access callback' => 'user_access',
'access arguments' => array(
'administer site configuration',
),
);
return $items;
}
function fb_social_send_content_extra_fields($type_name) {
if (fb_social_send_type($type_name) && variable_get('fb_social_send_location', 0)) {
$extras['fb_social_send_widget'] = array(
'label' => t('Facebook socials send widget'),
'description' => t('The facebook send pluging widget'),
'weight' => -10,
);
return $extras;
}
}
function fb_social_send_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'view':
if ($node->status && fb_social_send_type($node->type) && variable_get('fb_social_send_location', 0)) {
if ($a4 || !$a3 || variable_get('fb_social_send_display_teasers', 1) && $a3) {
$output = theme('fb_social_send_widget', fb_social_url('node/' . $node->nid));
$weight = module_exists('content') ? content_extra_field_weight($node->type, 'fb_social_send_widget') : -10;
$node->content['fb_social_send_widget'] = array(
'#weight' => $weight,
'#value' => $output,
);
}
}
break;
}
}
function fb_social_send_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks['send'] = array(
'info' => t('fb social: send'),
);
return $blocks;
case 'view':
switch ($delta) {
case 'send':
$url = fb_social_url($_GET['q']);
return array(
'subject' => t(''),
'content' => theme('fb_social_send_widget', $url),
);
}
break;
}
}
function fb_social_send_theme() {
return array(
'fb_social_send_widget' => array(
'arguments' => array(
'url' => NULL,
),
),
'fb_social_send_block_send_view' => array(),
);
}
function theme_fb_social_send_widget($url) {
global $_fb_script_init;
$_fb_script_init = TRUE;
$attrs = array(
'href' => $url,
'font' => variable_get('fb_social_send_font', ""),
'colorscheme' => variable_get('fb_social_send_colorscheme', 'light'),
);
$attrs = drupal_attributes($attrs);
return '<div class="fb-social-send-widget"><fb:send ' . $attrs . '></fb:send></div>';
}
function fb_social_send_link($type, $object, $teaser = FALSE) {
if ('node' != $type) {
return;
}
if (!$object->status) {
return;
}
if ($teaser && !variable_get('fb_social_send_display_teasers', 1)) {
return;
}
if (variable_get('fb_social_send_location', 0)) {
return;
}
$links = array();
if ($type == 'node' && fb_social_send_type($object->type)) {
$links['fb_social_send'] = array(
'title' => theme('fb_social_send_widget', fb_social_url('node/' . $object->nid)),
'html' => TRUE,
);
}
return $links;
}
function fb_social_send_type($type) {
$fb_send_types = variable_get('fb_social_send_node_types', array());
return isset($fb_send_types[$type]) && $fb_send_types[$type] ? TRUE : FALSE;
}
function fb_social_send_views_api() {
return array(
'api' => '2.0',
);
}