/[drupal]/contributions/modules/lastfmsimple/lastfmsimple.admin.inc
ViewVC logotype

Contents of /contributions/modules/lastfmsimple/lastfmsimple.admin.inc

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


Revision 1.2 - (show annotations) (download) (as text)
Sun Apr 5 20:49:17 2009 UTC (7 months, 3 weeks ago) by mikereem
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--3
Changes since 1.1: +112 -0 lines
File MIME type: text/x-php
Added feature by request: changeable statistic line display type (link/text).
1 <?php
2
3 /**
4 * @file
5 * All functions related to the lastfmsimple adminstration
6 */
7
8 /**
9 * Generates the Last.fm Sipmle Stats admininistration form located at
10 * ?q=admin/settings/lastfmsimple.
11 */
12 function lastfmsimple_admin_settings() {
13 // Get fields from the profile.module of the type 'textfield'.
14 $options = _lastfmsimple_get_textfield_fields();
15
16 // If there aren't any 'textfield' fields, throw an error and return an empty form
17 if (empty($options)) {
18 drupal_set_message(t('No profile fields of type \'textfield\' were found, please <a href="@profile-settings-page">create one here</a>.', array('@profile-settings-page' => url('admin/user/profile/add/textfield'))), 'error');
19 return;
20 }
21
22 $options = array('') + $options;
23 // Fieldset for general settings
24 $form['lastfmsimple_general_settings'] = array(
25 '#type' => 'fieldset',
26 '#title' => t('General settings'),
27 '#collapsible' => TRUE,
28 '#collapsed' => FALSE,
29 );
30
31 $form['lastfmsimple_general_settings']['lastfmsimple_username_field_id'] = array(
32 '#type' => 'select',
33 '#title' => t('Profile field'),
34 '#default_value' => variable_get('lastfmsimple_username_field_id', NULL),
35 '#description' => t("Select which profile field of type 'textfield' you want to use as Last.fm username."),
36 '#options' => $options,
37 '#required' => TRUE,
38 );
39
40 // Fieldset for update settings
41 $form['lastfmsimple_update_settings'] = array(
42 '#type' => 'fieldset',
43 '#title' => t('Update settings'),
44 '#collapsible' => TRUE,
45 '#collapsed' => FALSE,
46 );
47
48 $form['lastfmsimple_update_settings']['lastfmsimple_update_method'] = array(
49 '#type' => 'radios',
50 '#title' => t('Update method'),
51 '#description' => t('Whether feeds are updated through Drupal cron or on request. Please note updating on request might cause some slowness.'),
52 '#options' => array(
53 LASTFMSIMPLE_UPDATE_CRON => t('Drupal cron'),
54 LASTFMSIMPLE_UPDATE_REQUEST => t('On request'),
55 ),
56 '#default_value' => variable_get('lastfmsimple_update_method', LASTFMSIMPLE_UPDATE_DEFAULT),
57 '#required' => TRUE,
58 );
59
60 $form['lastfmsimple_update_settings']['lastfmsimple_interval'] = array(
61 '#type' => 'select',
62 '#title' => t('Update interval'),
63 '#description' => t('Select the interval fetched data should be updated. This does not apply when a feed has a usable Expires header.'),
64 '#options' => array(
65 0 => t('Check always'),
66 5 => t('@minutes minutes', array('@minutes' => 5)),
67 15 => t('@minutes minutes', array('@minutes' => 15)),
68 30 => t('@minutes minutes', array('@minutes' => 30)),
69 60 => t('Hourly'),
70 120 => t('@hours hours', array('@hours' => 2)),
71 180 => t('@hours hours', array('@hours' => 3)),
72 360 => t('@hours hours', array('@hours' => 6)),
73 720 => t('@hours hours', array('@hours' => 12)),
74 1440 => t('Daily'),
75 ),
76 '#default_value' => variable_get('lastfmsimple_interval', 5),
77 '#required' => TRUE,
78 );
79
80 // Fieldset for the lastfmsimple block.
81 $form['lastfmsimple_block'] = array(
82 '#type' => 'fieldset',
83 '#title' => t('Last.fm Simple Stats block settings'),
84 '#collapsible' => TRUE,
85 '#collapsed' => FALSE,
86 );
87
88 $form['lastfmsimple_block']['lastfmsimple_block_stattype'] = array(
89 '#type' => 'select',
90 '#title' => t('Set Last.fm Simple Stats block statistic type'),
91 '#default_value' => variable_get('lastfmsimple_block_stattype', LASTFMSIMPLE_BLOCK_STAT_TYPE_WEEKLYARTISTCHART),
92 '#description' => t("Select the statistic type you want to show on the block."),
93 '#options' => array(
94 LASTFMSIMPLE_BLOCK_STAT_TYPE_WEEKLYARTISTCHART => t('Weekly artist chart'),
95 LASTFMSIMPLE_BLOCK_STAT_TYPE_RECENTTRACKS => t('Recent tracks'),
96 ),
97 );
98
99 $form['lastfmsimple_block']['lastfmsimple_statline_display'] = array(
100 '#type' => 'radios',
101 '#title' => t('Display of stats'),
102 '#description' => t('Choose the display type of the lines of statistics.'),
103 '#options' => array(
104 LASTFMSIMPLE_STATLINE_LINK => t('Link to Last.fm'),
105 LASTFMSIMPLE_STATLINE_TEXT => t('Plain text'),
106 ),
107 '#default_value' => variable_get('lastfmsimple_statline_display', LASTFMSIMPLE_STATLINE_DEFAULT),
108 '#required' => TRUE,
109 );
110
111 return system_settings_form($form);
112 }

  ViewVC Help
Powered by ViewVC 1.1.2