/[drupal]/contributions/modules/amatomu/amatomu.module
ViewVC logotype

Contents of /contributions/modules/amatomu/amatomu.module

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


Revision 1.2 - (show annotations) (download) (as text)
Sun Sep 14 19:02:46 2008 UTC (14 months, 2 weeks ago) by stefanor
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +11 -10 lines
File MIME type: text/x-php
Drupal 6 support
1 <?php
2 // $Id: amatomu.module,v 1.1 2007/12/31 14:51:30 stefanor Exp $
3 /*
4 * Drupal Module: Amatomu
5 * Adds the required Javascript to the bottom of all your Drupal pages
6 * to allow tracking by the Amatomu.
7 *
8 * In the future, it should be extended to support other Amatomu functions, too.
9 *
10 * @author: Stefano Rivera <http://rivera.za.net/me/contact/>
11 */
12
13 /**
14 * Help hook:
15 * Display help and module information
16 * @param section which section of the site we're displaying help
17 * @return help text for section
18 */
19 function amatomu_help($path, $arg) {
20 switch ($path) {
21 case "admin/help#amatomu":
22 return('<p>' . t("Integration with amatomu.com. At the moment, only provides stats tracking") . '</p>');
23 }
24 return('');
25 }
26
27 /**
28 * Permissions hook:
29 * Valid permissions for this module
30 * @return array An array of valid permissions for the onthisdate module
31 */
32 function amatomu_perm() {
33 return array('administer amatomu');
34 }
35
36 /**
37 * Administration page
38 * @return the form for this module's admin page
39 */
40 function amatomu_admin() {
41 $form['amatomu_cid'] = array(
42 '#type' => 'textfield',
43 '#title' => t('Amatomu CID'),
44 '#default_value' => variable_get('amatomu_cid', ''),
45 '#size' => 40,
46 '#maxlength' => 40,
47 '#description' => t('The CID code, as obtained from Amatomu.com\'s "Embed code" page'),
48 '#required' => TRUE,
49 );
50
51 return system_settings_form($form);
52 }
53
54 /**
55 * Menu hook:
56 * Administration page
57 * @return the menu for this module
58 */
59 function amatomu_menu() {
60 $items = array();
61
62 $items['admin/settings/amatomu'] = array(
63 'title' => 'Amatomu',
64 'description' => 'Administer the Amatomu integration module',
65 'page callback' => 'drupal_get_form',
66 'page arguments' => array('amatomu_admin'),
67 'access arguments' => array('administer amatomu'),
68 'type' => MENU_NORMAL_ITEM,
69 );
70
71 return $items;
72 }
73
74 /**
75 * Footer hook:
76 * Insert the Amatomu.com tracking code.
77 * @param main Whether the current page is the front page of the site.
78 * @return The HTML to be inserted.
79 */
80 function amatomu_footer($main = 0) {
81 $cid = variable_get('amatomu_cid', '');
82
83 if ('' == $cid) {
84 return "<!-- Amatomu.com: No CID set, so no tracking -->\n";
85 }
86
87 return '<script type="text/javascript" src="http://www.amatomu.com/embed.php?cid=' . check_plain($cid) . "\"></script>\n";
88 }
89
90 /**
91 * Block hook:
92 * Display Amatomu.com tag cloud.
93 * @param op What kind of information to retrieve about the block or blocks?
94 * @param delta Which block to return
95 * @param edit If $op is 'save', the submitted form data from the configuration form.
96 * @return Return data for op
97 */
98 function amatomu_block($op = 'list', $delta = 0, $edit = array()) {
99 if ('list' == $op) {
100 $block[0]["info"] = t("Amatomu.com South African blogs: What's hot");
101 return $block;
102 }
103 else if ('view' == $op) {
104 $block['subject'] = "South African blogs: What's hot";
105 $block['content'] = '<style type="text/css">#amaheader { display: none; }</style>' . "\n"
106 . '<script language="javascript" src="http://www.amatomu.com/widgets/cloud.php"></script>';
107 return $block;
108 }
109 }

  ViewVC Help
Powered by ViewVC 1.1.2