/[drupal]/contributions/modules/service_links/service_links.api.php
ViewVC logotype

Diff of /contributions/modules/service_links/service_links.api.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Fri Aug 14 00:36:27 2009 UTC revision 1.1.2.1, Fri Aug 14 00:36:27 2009 UTC
# Line 0  Line 1 
1    <?php
2    // $Id$
3    
4    /**
5     * @file
6     * Provides documentation for the Service Links API.
7     */
8    
9    /**
10     * Obtains all available service links.
11     * @return
12     *   An array containing all service links, keyed by name.
13     */
14    function hook_service_links() {
15      $links = array();
16    
17      $links['myservice'] = array(
18        // The name of the service.
19        'name' => 'MyService',
20        // A short description for the link.
21        'description' => t('Share this post on MyService'),
22        // The link's URL. Available values are:
23        //   <encoded-url>, <encoded-title>, <encoded-teaser>, <teaser>, <short-url>,
24        // <source>, <node-id>, <url>, and <title>.
25        'link' => 'http://example.com/?url=<encoded-url>&title=<encoded-title>&summary=<encoded-teaser>',
26        // The service's small share icon. This is the relative path from Drupal's
27        // base path, or the absolute URL.
28        'icon' => drupal_get_path('module', 'myservice') .'/myservice.png',
29        // Any additional attributes to apply to the element.
30        'attributes' => array(
31          'class' => 'myservice-special-class', // A special class.
32          'style' => 'text-decoration: underline;', // Apply any special inline styles.
33        ),
34        // JavaScript that is added when this link is processed.
35        'javascript' => drupal_get_path('module', 'myservice') .'/myservice.js',
36        // CSS that is added when this link is processed.
37        'css' => drupal_get_path('module', 'myservice') .'/myservice.css',
38        // A PHP function callback that is invoked when the link is created.
39        'callback' => 'myservice_callback',
40      );
41    
42      return $links;
43    }
44    
45    /**
46     * Example callback from the Service Links.
47     *
48     * @param $service
49     *   The service that is being used.
50     * @param $context
51     *   An array containing all information about the item being shared.
52     */
53    function myservice_callback($service, $context) {
54    
55    }
56    
57    /**
58     * Allows alteration of the Service Links.
59     *
60     * @param $links
61     *   The constructed array of service links.
62     */
63    function hook_service_links_alter(&$links) {
64      if (isset($links['myservice'])) {
65        // Change the icon of MyService.
66        $links['myservice']['icon'] = 'http://drupal.org/misc/favicon.ico';
67      }
68    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.2