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

Contents of /contributions/modules/feedjit/feedjit.module

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


Revision 1.4 - (show annotations) (download) (as text)
Wed Jul 23 12:55:34 2008 UTC (16 months ago) by lyricnz
Branch: MAIN
CVS Tags: DRUPAL-6--1-0, HEAD
Changes since 1.3: +44 -50 lines
File MIME type: text/x-php
Implement simple color configuration
1 <?php
2 // $Id: feedjit.module,v 1.3 2008/07/23 05:53:17 lyricnz Exp $
3
4 /**
5 * @file
6 * A module for integrating with realtime traffic statistics as provided by http://feedjit.com/
7 *
8 * Please review the Feedjit Terms of Service before enabling this on your
9 * site. In particular the non-commercial clause, the right to redistribute
10 * your content, and deliver 3rd-party advertisements using the service.
11 * http://feedjit.com/static/TOS.html
12 */
13
14 global $_feedjit_color_names, $_feedjit_schemes;
15 $_feedjit_color_names = array('bc', 'tc', 'brd1', 'lnk', 'hc');
16 $_feedjit_schemes = array( // in color.module format
17 '#FFFFFF,#494949,#336699,#494949,#336699' => t('Feedjit Neutral'),
18 '#E8F6BE,#666666,#C4C4C4,#666666,#7F7F7F' => t('Feedjit Green'),
19 '#FFFFFF,#008000,#336699,#008000,#336699' => t('Seashore'),
20 '#FFFFFF,#5F5F5F,#0000FF,#5F5F5F,#0000FF' => t('Blues n Greys'),
21 '#CCCCCC,#333333,#666666,#333333,#000000' => t('Graphite'),
22 '#003366,#AECCEB,#6699CC,#AECCEB,#FFFFFF' => t('Blue Crush'),
23 '#028502,#D7D7D7,#00A700,#D7D7D7,#FFFFFF' => t('Arring Town'),
24 '#FFFFFF,#333333,#999999,#346BA4,#C13A10' => t('Rowser'),
25 '#003366,#FFFF00,#6699CC,#FFFF00,#FFFFFF' => t('Blue Angels'),
26 '#FFFFFF,#999999,#CCCCCC,#999999,#666666' => t('Grey Goose'),
27 '#000000,#8A8A8A,#D50000,#7C7C7C,#CC0000' => t('The Darkness'),
28 '#038CB6,#FB91D2,#FFBCBC,#E7E2A0,#C3FCFE' => t('Birthday Cake'),
29 '#000000,#FF0198,#FFACDD,#FF0198,#FF84CD' => t('Pink on Black'),
30 );
31
32
33
34 /**
35 * Implementation of hook_block().
36 */
37 function feedjit_block($op = 'list', $delta = 0, $edit = array()) {
38 switch ($op) {
39 case 'list':
40 $blocks[0] = array('info' => t('Feedjit Live Traffic Feed'), 'pages' => "admin\nadmin/*");
41 $blocks[1] = array('info' => t('Feedjit Live Traffic Map'), 'pages' => "admin\nadmin/*");
42 $blocks[2] = array('info' => t('Feedjit Live Recommended Reading'), 'pages' => "admin\nadmin/*");
43 $blocks[3] = array('info' => t('Feedjit Live Page Popularity'), 'pages' => "admin\nadmin/*");
44 return $blocks;
45 break;
46
47 case 'configure':
48 return _feedjit_block_configure($delta);
49 break;
50
51 case 'save':
52 return _feedjit_block_save($delta, $edit);
53 break;
54
55 case 'view':
56 return _feedjit_block_view($delta);
57 break;
58 } // switch
59 }
60
61
62 /**
63 * Configure the colors for this block. For now all blocks use the same form.
64 */
65 function _feedjit_block_configure($delta) {
66 global $_feedjit_schemes;
67 $schemes = array_keys($_feedjit_schemes);
68
69 $_feedjit_info[''] = t('Custom');
70 $form['scheme'] = array(
71 '#type' => 'select',
72 '#title' => t('Color set'),
73 '#options' => $_feedjit_schemes,
74 '#default_value' => variable_get('feedjit_scheme_'. $delta, $schemes[0]),
75 );
76
77 return $form;
78 }
79
80 function _feedjit_block_save($delta, $edit) {
81 variable_set('feedjit_scheme_'. $delta, $edit['scheme']);
82 }
83
84 function _feedjit_block_view($delta) {
85
86 // determine the current colors
87 global $_feedjit_color_names, $_feedjit_schemes;
88 $schemes = array_keys($_feedjit_schemes);
89 $current_scheme = variable_get('feedjit_scheme_'. $delta, $schemes[0]);
90 $args = array_combine($_feedjit_color_names, explode(',#', substr($current_scheme, 1)));
91
92 switch ($delta) {
93 case 0:
94 $block['subject'] = t('Live Traffic Feed');
95 $block['content'] = _feedjit_script_html('http://feedjit.com/serve/', $args, $block['subject']);
96 break;
97
98 case 1:
99 $block['subject'] = t('Live Traffic Map');
100 $block['content'] = _feedjit_script_html('http://feedjit.com/map/', $args, $block['subject']);
101 break;
102
103 case 2:
104 $block['subject'] = t('Live Recommended Reading');
105 $block['content'] = _feedjit_script_html('http://feedjit.com/coFilter/', $args, $block['subject']);
106 break;
107
108 case 3:
109 $block['subject'] = t('Live Page Popularity');
110 $block['content'] = _feedjit_script_html('http://feedjit.com/popPages/', $args, $block['subject']);
111 break;
112 } // switch
113
114 return $block;
115 }
116
117 function _feedjit_script_html($path, $args, $linktext) {
118 $options = array(
119 'query' => drupal_query_string_encode($args),
120 'external' => TRUE,
121 'absolute' => TRUE,
122 );
123
124 return
125 '<script type="text/javascript" src="'. url($path, $options) .'"></script>'.
126 '<noscript>'. l($linktext, 'http://feedjit.com/') .'</noscript>';
127 }

  ViewVC Help
Powered by ViewVC 1.1.2