diff -urp 5.x-2.x-dev/share.info 6.x-2.x-dev/share.info --- 5.x-2.x-dev/share.info 2008-04-12 10:11:20.000000000 +1000 +++ 6.x-2.x-dev/share.info 2008-06-10 08:29:35.000000000 +1000 @@ -1,8 +1,9 @@ ; $Id: share.info,v 1.1.4.1 2008/03/25 21:02:44 greenskin Exp $ name = Share -description = "Makes Service Links module more eye appealing and adds some extra features." +description = Makes Service Links module more eye appealing and adds some extra features. +core = 6.x ; Information added by drupal.org packaging script on 2008-04-12 -version = "5.x-2.x-dev" +version = "6.x-2.x-dev" project = "share" datestamp = "1207959080" diff -urp 5.x-2.x-dev/share.install 6.x-2.x-dev/share.install --- 5.x-2.x-dev/share.install 2008-03-26 08:02:44.000000000 +1100 +++ 6.x-2.x-dev/share.install 2008-06-10 08:56:34.000000000 +1000 @@ -1,6 +1,10 @@ '0') { + } + else if (variable_get('service_links_in_node', 2) > '0') { variable_set('service_links_in_share_node', variable_get('service_links_in_node', 2)); variable_del('service_links_in_node'); } variable_del('share_service_links'); } - + // For Forward module if (variable_get('forward_form_type', 'link') == 'link' && variable_get('share_forward', 0)) { variable_set('forward_form_type', 'share_link'); } - + if (variable_get('forward_form_type', 'link') == 'share') { variable_set('forward_form_type', 'share_form'); } @@ -31,11 +36,11 @@ function share_update_1() { if (variable_get('share_forward_form', 0)) { variable_set('share_forward', variable_get('share_forward_form', 0)); } - + // For Share Block variable_get('share_block_collapsed', 1); variable_del('share_block_link'); - + variable_del('share_tab_email'); variable_del('share_tab_social'); return array(); @@ -44,10 +49,10 @@ function share_update_1() { function share_update_2() { variable_set('share_node_types', variable_get('share_share_this_node_types', array())); variable_del('share_share_this_node_types'); - + variable_set('share_category_types', variable_get('share_share_this_category_types', array())); variable_del('share_share_this_category_types'); - + variable_set('share_where', variable_get('share_share_this_where', 0)); variable_del('share_share_this_where'); return array(); @@ -59,8 +64,8 @@ function share_uninstall() { variable_del('share_forward'); variable_del('share_forward_form'); variable_del('share_service_links'); - + variable_del('share_effects'); variable_del('share_tab_email'); variable_del('share_tab_social'); -} \ No newline at end of file +} diff -urp 5.x-2.x-dev/share.module 6.x-2.x-dev/share.module --- 5.x-2.x-dev/share.module 2008-04-12 08:48:47.000000000 +1000 +++ 6.x-2.x-dev/share.module 2008-06-10 08:55:50.000000000 +1000 @@ -2,6 +2,10 @@ // $Id: share.module,v 1.27.2.4 2008/04/11 22:48:47 greenskin Exp $ /** + * @file + */ + +/** * Implementation of hook_perm(). */ function share_perm() { @@ -9,31 +13,39 @@ function share_perm() { } /** + * Implementation of hook_theme(). + */ +function share_theme() { + return array( + 'share_page' => array( + 'arguments' => array('data' => NULL), + ), + 'share_css' => array( + 'arguments' => array('block' => FALSE), + ), + ); +} + +/** * Implementation of hook_menu(). */ -function share_menu($may_cache) { - $items = array(); - if (!$may_cache) { - if (is_numeric($arg1 = arg(1))) { - $items[] = array( - 'path' => 'share', - 'title' => t("Share"), - 'description' => t("Share this page"), - 'callback' => 'share_page', - 'callback arguments' => array($arg1), - 'type' => MENU_CALLBACK, - 'access' => node_access('view', node_load($arg1)) - ); - } - } else { - $items[] = array( - 'path' => 'admin/settings/share', - 'title' => t('Share'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('share_settings'), - 'access' => user_access('administer share') - ); - } +function share_menu() { + + $items['share/%'] = array( + 'title' => "Share", + 'description' => "Share this page", + 'page callback' => 'share_page', + 'page arguments' => array(1), + 'type' => MENU_CALLBACK, + 'access callback' => 'node_access', + 'access arguments' => array('view', 1), + ); + $items['admin/settings/share'] = array( + 'title' => 'Share', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('share_settings'), + 'access arguments' => array('administer share') + ); return $items; } @@ -82,7 +94,7 @@ function share_settings() { '#default_value' => variable_get('share_view', 0), '#options' => array(t('Teasers'), t('Full-page'), t('Teasers and full-page')) ); - + // Share This $form['share_this_settings'] = array( '#type' => 'fieldset', @@ -98,7 +110,7 @@ function share_settings() { '#description' => t('Javascript code provided by Share This. You can generate your own code !here.', array('!here' => l(t('here'), 'http://sharethis.com/publisher?type=stapi'))), '#default_value' => variable_get('share_share_this_code', $share_code) ); - + // SHARE $form['share'] = array( '#type' => 'fieldset', @@ -151,18 +163,18 @@ function share_settings() { '#default_value' => variable_get('share_link_codes', array('direct' => 0, 'html' => 0, 'forum' => 0)), '#options' => array('direct' => t("Direct URL"), 'html' => t("HTML Code"), 'forum' => t("Forum Code")) ); - + return system_settings_form($form); } /** * Implementation of hook_form_alter(). */ -function share_form_alter($form_id, &$form) { +function share_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'service_links_admin_settings') { - drupal_add_js(drupal_get_path('module', 'share').'/js/settings.js'); + drupal_add_js(drupal_get_path('module', 'share') .'/js/settings.js'); $form['how_to_show_the_links']['service_links_in_node']['#default_value'] = variable_get('service_links_in_node', 0); - + $form['how_to_show_the_links']['share'] = array( '#type' => 'fieldset', '#title' => t("Share"), @@ -190,12 +202,12 @@ function share_form_alter($form_id, &$fo '#value' => '
' ); $form['how_to_show_the_links']['service_links_style']['#weight'] = 1; - $form['#validate']['share_service_links_validate'] = array(); + $form['#element_validate']['share_service_links_validate'] = array(); } if ($form_id == 'forward_admin_settings') { $form['forward_options']['forward_form_type']['#options']['share_link'] = 'Link in Share'; $form['forward_options']['forward_form_type']['#options']['share_form'] = 'Form in Share'; - + $form['share']['share_forward'] = array( '#type' => 'checkbox', '#title' => t("Share Forward Form"), @@ -206,26 +218,26 @@ function share_form_alter($form_id, &$fo } } -function share_service_links_validate($form_id, $form_values) { - if ($form_values['service_links_in_share_node'] > 0) { - if ($form_values['service_links_in_links'] > 0) { +function share_service_links_validate($form, &$form_state) { + if ($form_state['values']['service_links_in_share_node'] > 0) { + if ($form_state['values']['service_links_in_links'] > 0) { form_set_error('service_links_in_links', "'Share service links in node' cannot be enabled if 'Service links in links' is also enabled."); } - if ($form_values['service_links_in_node'] > 0) { + if ($form_state['values']['service_links_in_node'] > 0) { form_set_error('service_links_in_node', "'Share service links in node' cannot be enabled if 'Service links in node' is also enabled."); } - if ($form_values['service_links_in_share_links'] > 0) { + if ($form_state['values']['service_links_in_share_links'] > 0) { form_set_error('service_links_in_share_links', "'Share service links in node' cannot be enabled if 'Share service links in links' is also enabled."); } } - if ($form_values['service_links_in_share_links'] > 0) { - if ($form_values['service_links_in_links'] > 0) { + if ($form_state['values']['service_links_in_share_links'] > 0) { + if ($form_state['values']['service_links_in_links'] > 0) { form_set_error('service_links_in_links', "'Share service links in links' cannot be enabled if 'Service links in links' is also enabled."); } - if ($form_values['service_links_in_node'] > 0) { + if ($form_state['values']['service_links_in_node'] > 0) { form_set_error('service_links_in_node', "'Share service links in links' cannot be enabled if 'Service links in node' is also enabled."); } - if ($form_values['service_links_in_share_node'] > 0) { + if ($form_state['values']['service_links_in_share_node'] > 0) { form_set_error('service_links_in_share_node', "'Share service links in links' cannot be enabled if 'Share service links in node' is also enabled."); } } @@ -262,9 +274,9 @@ function share_nodeapi(&$node, $op, $tea $node->content['share_share_this'] = array( '#value' => "", '#weight' => 10 ); @@ -333,12 +345,12 @@ function share_link($type, $node = NULL, $links['share_share_this'] = array( 'title' => "", 'html' => TRUE, - 'attributes' => array('id' => 'share_'.$node->nid) + 'attributes' => array('id' => 'share_'. $node->nid) ); return $links; } @@ -353,16 +365,16 @@ function share_link($type, $node = NULL, switch ($share_view) { case "1": if ($teaser) { - $links['share_group_'.$node->nid.' share'] = share_display('link', $node); + $links['share_group_'. $node->nid .' share'] = share_display('link', $node); } break; case "2": if (!$teaser) { - $links['share_group_'.$node->nid.' share'] = share_display('link', $node); + $links['share_group_'. $node->nid .' share'] = share_display('link', $node); } break; case "3": - $links['share_group_'.$node->nid.' share'] = share_display('link', $node); + $links['share_group_'. $node->nid .' share'] = share_display('link', $node); break; } return $links; @@ -411,7 +423,7 @@ function share_block($op = 'list', $delt if (user_access('use service links')) { if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2)) { theme('share_css', TRUE); - $node = node_load(arg(1)); + $node = menu_get_object(); $links_show = _service_links_show($node->type, $node->nid); if ($links_show) { $block['content'] = $content = share_display('block', $node); @@ -424,7 +436,7 @@ function share_block($op = 'list', $delt } } -function share_display($type,$node) { +function share_display($type, $node) { static $share = NULL; if ($share == NULL) { $share = array( @@ -438,7 +450,7 @@ function share_display($type,$node) { switch ($type) { case 'node': $node->content['service_links'] = array( - '#value' => '
'.share_render($node).'
', + '#value' => '
'. share_render($node) .'
', '#weight' => 10 ); return $node; @@ -446,11 +458,11 @@ function share_display($type,$node) { $link = array( 'title' => share_render($node, TRUE), 'html' => TRUE, - 'attributes' => array('id' => 'share_'.$node->nid) + 'attributes' => array('id' => 'share_'. $node->nid) ); return $link; case 'block': - return '
'.share_render($node, FALSE, TRUE).'
'; + return '
'. share_render($node, FALSE, TRUE) .'
'; } } @@ -459,31 +471,32 @@ function share_render($node, $is_link = $links = ''; foreach ($service_links as $service) { if (!is_array($service)) { - $links.= $service; + $links .= $service; } } $output = ''; if (!empty($links)) { theme('share_css'); if (variable_get('share_effects', 0)) { - drupal_add_js(drupal_get_path('module', 'share').'/js/share_effects.js'); - } else { - drupal_add_js(drupal_get_path('module', 'share').'/js/share.js'); + drupal_add_js(drupal_get_path('module', 'share') .'/js/share_effects.js'); + } + else { + drupal_add_js(drupal_get_path('module', 'share') .'/js/share.js'); } $nid = $node->nid; if ($is_block) { $nid = 'block'; } if (!$is_link) { - $output.= '
'; + $output .= '
'; } - $output.= l(t('Share'), 'share/'.$node->nid, array('class' => 'share_link', 'onclick' => 'return false;')); - $output.= ''; + $output .= l(t('Share'), 'share/'. $node->nid, array('class' => 'share_link', 'onclick' => 'return false;')); + $output .= ''; if (!$is_link) { - $output.= '
'; + $output .= '
'; } } return $output; @@ -493,61 +506,61 @@ function _share_get_tabs() { $codes = NULL; $count = array_count_values(variable_get('share_link_codes', array('direct' => 0, 'html' => 0, 'forum' => 0))); if ($count[0] < 3 || !isset($count[0])) { - $codes = '
  • '.l(t('Link Codes'), '', array('onclick' => 'return false;')).'
  • '; + $codes = '
  • '. l(t('Link Codes'), '', array('onclick' => 'return false;')) .'
  • '; } $forward = NULL; $form_type = variable_get('forward_form_type', 'link'); if (module_exists('forward') && user_access('access forward') && ($form_type = 'share_form' || variable_get('share_forward', 0))) { - $forward = '
  • '.l(t('E-Mail'), '', array('onclick' => 'return false;')).'
  • '; + $forward = '
  • '. l(t('E-Mail'), '', array('onclick' => 'return false;')) .'
  • '; } if (variable_get('share_forward', 0)) { $close = NULL; if (variable_get('share_block_collapsible', 1)) { - $close = ''.t('Close').''; + $close = ''. t('Close') .''; } - return $close. + return $close . ''; } } function _share_get_content($links, $nid) { $output = '
    '; - $output.= ''; - $output.= '
    '; - $form_type = variable_get('forward_form_type', 'link'); - if (module_exists('forward') && user_access('access forward') && ($form_type == 'share_form' || variable_get('share_forward', 0))) { - $output.= ''; - } - $link_codes = variable_get('share_link_codes', array('direct' => 0, 'html' => 0, 'forum' => 0)); - $count = array_count_values($link_codes); - if ($count[0] < 3 || !isset($count[0])) { - drupal_add_js(drupal_get_path('module', 'share').'/js/link_codes.js'); - $output.= ''; + $output .= '
    '; + } + $output .= ''; return $output; } function _share_get_link_codes($op, $nid) { $node = node_load($nid); - $alias = drupal_get_path_alias('node/'.$node->nid); + $alias = drupal_get_path_alias('node/'. $node->nid); switch ($op) { case "direct": - return ''; + return ''; case "html": - return ''; + return ''; case "forum": - return ''; + return ''; } } @@ -563,7 +576,7 @@ function share_form($nid = null) { else { $emailtype = 'postcard'; } - + $form['yemail'] = array( '#type' => 'textfield', '#title' => t('Your Email'), @@ -620,19 +633,19 @@ function share_form($nid = null) { } function share_forms() { - # get the form id + // get the form id $args = func_get_args(); $form_id = $args[0][0]; - # Ensure we map a callback for our form and not something else + // Ensure we map a callback for our form and not something else $forms = array(); if (strpos($form_id, "share_form") === 0) { - # Let the forms API know where to get the form data corresponding - # to this form id. + // Let the forms API know where to get the form data corresponding + // to this form id. $forms[$form_id] = array('callback' => 'share_form'); } - + return $forms; } @@ -650,7 +663,7 @@ function share_page($nid) { } $data->node = node_view($node); - return theme('share_page',$data); + return theme('share_page', $data); } } drupal_not_found(); @@ -660,31 +673,32 @@ function theme_share_page($data) { $links = ''; $output = $data->description; - $output .= ""; + $output .= "
    ".$data->social['title']."
    "; if ($data->forward['title']) { - $output .= ""; + $output .= ""; } $output .= ""; - $output .= ""; + $output .= ""; if ($data->forward['form']) { - $output .= ""; + $output .= ""; } $output .= ""; - $colspan = $data->forward?" colspan='2'":NULL; - $output .= "".$data->node."
    ". $data->social['title'] ."".$data->forward['title']."". $data->forward['title'] ."
    ".$links."
    ". $links ."".$data->forward['form']."". $data->forward['form'] ."
    "; - + $colspan = $data->forward ? " colspan='2'" : NULL; + $output .= "". $data->node .""; + return $output; } function theme_share_css($block = FALSE) { if (!$block) { - drupal_add_css(drupal_get_path('module', 'share'). '/share.css', 'theme', 'screen'); - } else { - drupal_add_css(drupal_get_path('module', 'share'). '/share_block.css', 'theme', 'screen'); + drupal_add_css(drupal_get_path('module', 'share') .'/share.css', 'theme', 'screen'); + } + else { + drupal_add_css(drupal_get_path('module', 'share') .'/share_block.css', 'theme', 'screen'); } } @@ -695,7 +709,7 @@ function _share_show($type, $nid) { $links_show = FALSE; $node_type = in_array($type, variable_get('share_node_types', array()), TRUE); if (module_exists('taxonomy')) { - $terms = taxonomy_node_get_terms($nid); + $terms = taxonomy_node_get_terms(node_load($nid)); foreach ($terms as $term) { $category_type = in_array($term->tid, variable_get('share_category_types', array()), FALSE); } @@ -714,7 +728,7 @@ function _share_service_links_where() { 'Service Links in Node' => variable_get('service_links_in_node', 0), 'Service Links in Links' => variable_get('service_links_in_links', 0) ); - + $output = array(); foreach ($where as $k => $v) { if ($v > 0) { @@ -734,4 +748,4 @@ function _share_service_links_where() { } $output = implode('
    ', $output); return $output; -} \ No newline at end of file +}