/[drupal]/contributions/modules/votesmart/votesmart.inc
ViewVC logotype

Diff of /contributions/modules/votesmart/votesmart.inc

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

revision 1.1, Wed Aug 6 00:27:37 2008 UTC revision 1.2, Sun Aug 10 01:42:51 2008 UTC
# Line 1  Line 1 
1  <?php // $Id$  <?php // $Id: votesmart.inc,v 1.1 2008/08/06 00:27:37 vauxia Exp $
2    
3  function votesmart_settings() {  function votesmart_settings() {
4    $form = array();    $form = array();
5    $form['votesmart_host'] = array(    $form['api'] = array(
6        '#type' => 'fieldset',
7        '#title' => ('API Settings'),
8        '#collapsible' => TRUE,
9        '#collapsed' => variable_get('votesmart_key', ''),
10      );
11      $form['api']['votesmart_host'] = array(
12      '#type' => 'textfield',      '#type' => 'textfield',
13      '#title' => t('Votesmart API server'),      '#title' => t('Votesmart API server'),
14      '#description' => t(''),      '#description' => t(''),
15      '#default_value' => variable_get('votesmart_host', 'http://api.votesmart.org/'),      '#default_value' => variable_get('votesmart_host', 'http://api.votesmart.org/'),
16    );    );
17    $form['votesmart_key'] = array(    $form['api']['votesmart_key'] = array(
18      '#type' => 'textfield',      '#type' => 'textfield',
19      '#title' => t('Votesmart API key'),      '#title' => t('Votesmart API key'),
20      '#description' => t(''),      '#description' => t(''),
# Line 18  function votesmart_settings() { Line 24  function votesmart_settings() {
24    return system_settings_form($form);    return system_settings_form($form);
25  }  }
26    
27  function votesmart_lists() {  function _votesmart_field_values($table, $data) {
28      $values = array();
29      // Make sure this is a valid table array.
30      if (!isset($table['votesmart'])) $table = current(votesmart_tables($table));
31    
32      foreach ($table['fields'] as $name => $info) {
33        if ($key = $info['votesmart']) {
34          if (isset($data[$key])) $values[$name] = (string) $data[$key];
35        }
36      }
37      return $values;
38    }
39    
40    function _votesmart_lists($filter = array()) {
41      if ($filter && !is_array($filter)) $filter = array($filter);
42    $lists = array();    $lists = array();
43    
44    $lists['states'] = array(    $lists['states'] = array(
# Line 97  function votesmart_lists() { Line 117  function votesmart_lists() {
117      'votesmart' => array('Votes.getBillsByOfficialYearOffice', array('candidateId', 'year', 'office'), 'bill'),      'votesmart' => array('Votes.getBillsByOfficialYearOffice', array('candidateId', 'year', 'office'), 'bill'),
118    );    );
119    
120      if ($filter) {
121        $ret = array();
122        foreach ($filter as $list) {
123          $ret[$list] = $lists[$list];
124        }
125        return $ret;
126      }
127    
128    return $lists;    return $lists;
129  }  }
130    
131  function votesmart_tables() {  function _votesmart_tables($filter = array()) {
132      if ($filter && !is_array($filter)) $filter = array($filter);
133    $tables = array();    $tables = array();
134    $tables['address'] = array(    $tables['address'] = array(
135    );    );
# Line 374  function votesmart_tables() { Line 403  function votesmart_tables() {
403    );    );
404    $tables['sig'] = array(    $tables['sig'] = array(
405      'description' => t('Special interest group'),      'description' => t('Special interest group'),
406                  'votesmart' => array('Rating.getSig', array('sigId'), 'sig'),                  'votesmart' => array('Rating.getSig', array('sigId')),
407      'fields' => array(      'fields' => array(
408        'sig_id' => array(        'sig_id' => array(
409          'type' => 'integer',          'type' => 'integer',
# Line 470  function votesmart_tables() { Line 499  function votesmart_tables() {
499    $tables['vote'] = array(    $tables['vote'] = array(
500    );    );
501    
502      if ($filter) {
503        $ret = array();
504        foreach ($filter as $table) {
505          $ret[$table] = $tables[$table];
506        }
507        return $ret;
508      }
509    
510    return $tables;    return $tables;
511  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.2