'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') ); } return $items; } function share_settings() { $form['share_tab_names'] = array( '#type' => 'fieldset', '#title' => t("Tab Names"), '#description' => t("Set names for the tabs provided in the Share popup."), '#collapsible' => TRUE, '#collapsed' => FALSE ); $form['share_tab_names']['share_tab_social'] = array( '#type' => 'textfield', '#title' => t("Service Links Tab"), '#default_value' => variable_get('share_tab_social', t("Social Web")), '#required' => FALSE ); $form['share_tab_names']['share_tab_email'] = array( '#type' => 'textfield', '#title' => t("E-mail Tab"), '#default_value' => variable_get('share_tab_email', t("E-mail")), '#required' => FALSE ); $form['share_effects'] = array( '#type' => 'checkbox', '#title' => t("Effects"), '#description' => t("Add animation to the opening and closing of the Share popup."), '#default_value' => variable_get('share_effects', 0) ); return system_settings_form($form); } /** * Implementation of hook_form_alter(). */ function share_form_alter($form_id, &$form) { if ($form_id == 'service_links_admin_settings') { $form['share'] = array( '#type' => 'fieldset', '#title' => t("Share"), '#description' => t("Extra features settings."), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE ); $form['share']['share_service_links'] = array( '#type' => 'checkbox', '#title' => t("Group Service Links"), '#description' => t("This will provide just one general link that opens a javascript window holding all the service links. If the viewer does not have javascript enabled, this settings makes no effect."), '#default_value' => variable_get('share_service_links', 0), '#required' => FALSE ); $form['#validate']['share_service_links_validate'] = array(); $form['buttons']['#weight'] = 2; } if ($form_id == 'forward_admin_settings') { $form['share'] = array( '#type' => 'fieldset', '#title' => t("Share"), '#description' => t("Extra features settings."), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => TRUE ); $form['share']['share_forward'] = array( '#type' => 'checkbox', '#title' => t("Group With Service Links"), '#description' => t("This will provide the forward link inside the Share link provided by Share module. If the form type selected above is link, it will be displayed in the same list as the Service Links. If the form type is share_form, it will be displayed in a tab."), '#default_value' => variable_get('share_forward', 0) ); $form['share']['share_forward_form'] = array( '#type' => 'checkbox', '#title' => t("Show Forward Form"), '#description' => t("Show Forward form as a tab in Share popup if form type is set to 'link'."), '#default_value' => variable_get('share_forward_form', 0) ); $form['buttons']['#weight'] = 2; $form['forward_options']['forward_show_teasers']['#description'] .= ". If Forward is set to 'Group with Service Links' then this does not take affect, change on Service Links settings page to display in teasers."; $form['forward_options']['forward_form_type']['#options']['share'] = 'share_form'; } } function share_service_links_validate($form_id, $form) { if ($form['share_service_links'] == 1) { if ($form['service_links_in_node'] != 0 && $form['service_links_in_links'] != 0) { form_set_error('service_links_in_links',"Share works correctly only if Service Links is displayed in either links or nodes, but not both. Please disabled one."); form_set_error('service_links_in_node'," "); } /*if ($form['service_links_in_links'] == 1 || $form['service_links_in_links'] == 3) { form_set_error('service_links_in_links',"Teasers do not work at this time with Share module. Please either turn off 'Group Service Links' or change 'Service links in nodes' to 'Disabled' or 'Full-page view'."); } if ($form['service_links_in_node'] == 1 || $form['service_links_in_node'] == 3) { form_set_error('service_links_in_node',"Teasers do not work at this time with Share module. Please either turn off 'Group Service Links' or change 'Service links in nodes' to 'Disabled' or 'Full-page view'."); }*/ } } /** * Implementation of hook_nodeapi(). */ function share_nodeapi(&$node, $op, $teaser, $page) { if (variable_get('share_service_links', 0) == 1) { $links_show = _service_links_show($node->type, $node->nid); if ($links_show && user_access('use service links')) { $node_links = variable_get('service_links_in_node', 0); switch ($op) { case 'view': switch ($node_links) { case "1": if ($teaser) { $node = share_link_display('node',$node); } break; case "2": if ($page) { $node = share_link_display('node',$node); } break; case "3": if ($teaser) { $node = share_link_display('node',$node); } if ($page) { $node = share_link_display('node',$node); } break; } break; } } } } /** * Implementation of hook_link(). */ function share_link($type, $node = NULL, $teaser = FALSE) { $links = array(); if (variable_get('share_service_links', 0) == 1) { $links_show = _service_links_show($node->type, $node->nid); if ($links_show && user_access('use service links')) { $link_links = variable_get('service_links_in_links', 0); switch ($link_links) { case "1": if ($teaser) { $links['share'.$node->nid.'_group share'] = share_link_display('link',$node); } break; case "2": if (!$teaser) { $links['share'.$node->nid.'_group share'] = share_link_display('link',$node); } break; case "3": $links['share'.$node->nid.'_group share'] = share_link_display('link',$node); break; } return $links; } } } /** * Implementation of hook_link_alter(). */ function share_link_alter(&$node, &$links) { if (variable_get('share_service_links', 0) == 1) { $links_show = _service_links_show($node->type, $node->nid); if ($links_show && user_access('use service links')) { $links_links = variable_get('service_links_in_links', 0); if ($links_links != 0) { $forward_form = share_forward_formtype($node->nid); if ($forward_form != '') { $menu = "
"; } else { $menu = NULL; } $share_links = ' '; if ($share_links != ' ') { drupal_add_js("$('li.share".$node->nid."_group').append(".drupal_to_js($share_links).');', 'inline', 'footer'); } } } } } function share_link_display($type,$node) { switch ($type) { case 'node': drupal_add_js(drupal_get_path('module', 'share').'/share.js'); drupal_add_js(array('share' => array('effects' => variable_get('share_effects', 0))), 'setting'); theme('share_css'); $forward_form = share_forward_formtype($node->nid); if ($forward_form != '') { $menu = " "; } else { $menu = NULL; } $node->content['service_links']['#value'] = preg_replace('/".$data->social['title']." | "; if ($data->forward['title']) { $output .= "".$data->forward['title']." | "; } $output .= "
---|---|
".$links." | "; if ($data->forward['form']) { $output .= "".$data->forward['form']." | "; } $output .= "
".$data->node." |