| 1 |
<?php // $Id: votesmart.inc,v 1.3 2008/08/17 15:36:33 vauxia Exp $
|
| 2 |
|
| 3 |
function votesmart_settings() {
|
| 4 |
$form = array();
|
| 5 |
$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',
|
| 13 |
'#title' => t('Votesmart API server'),
|
| 14 |
'#description' => t(''),
|
| 15 |
'#default_value' => variable_get('votesmart_host', 'http://api.votesmart.org/'),
|
| 16 |
);
|
| 17 |
$form['api']['votesmart_key'] = array(
|
| 18 |
'#type' => 'textfield',
|
| 19 |
'#title' => t('Votesmart API key'),
|
| 20 |
'#description' => t(''),
|
| 21 |
'#default_value' => variable_get('votesmart_key', ''),
|
| 22 |
);
|
| 23 |
|
| 24 |
return system_settings_form($form);
|
| 25 |
}
|
| 26 |
|
| 27 |
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])) {
|
| 35 |
$values[$name] = (string) $data[$key];
|
| 36 |
if ($func = $info['callback']) $values[$name] = $func($values[$name]);
|
| 37 |
}
|
| 38 |
}
|
| 39 |
}
|
| 40 |
return $values;
|
| 41 |
}
|
| 42 |
|
| 43 |
function _votesmart_set_query($request, $input = array()) {
|
| 44 |
$query = array();
|
| 45 |
foreach($request[1] as $name => $token) {
|
| 46 |
if (isset($input[$token])) {
|
| 47 |
$query[$name] = $input[$token];
|
| 48 |
}
|
| 49 |
}
|
| 50 |
$request[1] = $query;
|
| 51 |
return $request;
|
| 52 |
}
|
| 53 |
|
| 54 |
function _votesmart_lists($filter = array()) {
|
| 55 |
if ($filter && !is_array($filter)) $filter = array($filter);
|
| 56 |
$lists = array();
|
| 57 |
|
| 58 |
$lists['states'] = array(
|
| 59 |
'description' => t('State'),
|
| 60 |
'table' => 'state',
|
| 61 |
'votesmart' => array('State.getStateIDs', array(), 'list.state'),
|
| 62 |
'id' => 'stateId',
|
| 63 |
'name' => 'name',
|
| 64 |
);
|
| 65 |
|
| 66 |
$lists['counties'] = array(
|
| 67 |
'description' => t('Counties'),
|
| 68 |
'votesmart' => array('Local.getCounties', array('StateId' => 'state_id'), ''),
|
| 69 |
);
|
| 70 |
|
| 71 |
$lists['elections'] = array(
|
| 72 |
'description' => t('Elections by state'),
|
| 73 |
'votesmart' => array('Election.getElectionByYearState', array('stateId' => 'state_id', 'year' => 'year'), 'elections.election'),
|
| 74 |
);
|
| 75 |
|
| 76 |
$lists['office_types'] = array(
|
| 77 |
'description' => t('Office type'),
|
| 78 |
'votesmart' => array('Office.getTypes', array(), 'type'),
|
| 79 |
);
|
| 80 |
|
| 81 |
$lists['officials'] = array(
|
| 82 |
'description' => t('Officials'),
|
| 83 |
'votesmart' => array('Local.getOfficials', array('localId' => 'local_id'), ''),
|
| 84 |
);
|
| 85 |
|
| 86 |
$lists['office_branches'] = array(
|
| 87 |
'description' => t('Office branch'),
|
| 88 |
'votesmart' => array('Office.getBranches', array(), 'branch'),
|
| 89 |
);
|
| 90 |
|
| 91 |
$lists['office_levels'] = array(
|
| 92 |
'description' => t('Office level'),
|
| 93 |
'votesmart' => array('Office.getLevels', array(), 'level'),
|
| 94 |
);
|
| 95 |
|
| 96 |
$lists['sig_categories'] = array(
|
| 97 |
'description' => t('Special interest Category'),
|
| 98 |
'votesmart' => array('Rating.getCategories', array('stateId' => 'state_id'), 'category'),
|
| 99 |
);
|
| 100 |
|
| 101 |
$lists['sigs'] = array(
|
| 102 |
'description' => t('Special interest group'),
|
| 103 |
'table' => 'sig',
|
| 104 |
'votesmart' => array('Rating.getSigList', array('categoryId' => 'category_id', 'stateId' => 'state_id'), 'sig'),
|
| 105 |
);
|
| 106 |
|
| 107 |
$lists['bill_categories'] = array(
|
| 108 |
'description' => t('Bill Categories'),
|
| 109 |
'votesmart' => array('Votes.getCategories', array('stateId' => 'state_id', 'year' => 'year'), ''),
|
| 110 |
);
|
| 111 |
|
| 112 |
$lists['bills_by_year_state'] = array(
|
| 113 |
'description' => t('Bills by year'),
|
| 114 |
'table' => 'bill',
|
| 115 |
'votesmart' => array('Votes.getBillsByYearState', array('stateId' => 'state_id', 'year' => 'year'), 'bill'),
|
| 116 |
);
|
| 117 |
|
| 118 |
$lists['bills_by_category_year_state'] = array(
|
| 119 |
'description' => t('Votes by year, category and state'),
|
| 120 |
'table' => 'bill',
|
| 121 |
'votesmart' => array('Votes.getBillsByCategoryYearState', array('stateId' => 'state_id', 'year' => 'year', 'categoryId' => 'category_id'), 'bill'),
|
| 122 |
);
|
| 123 |
|
| 124 |
$lists['bills_by_official_year_office'] = array(
|
| 125 |
'description' => t('Votes by official, year and office'),
|
| 126 |
'table' => 'bill',
|
| 127 |
'votesmart' => array('Votes.getBillsByOfficialYearOffice', array('candidateId' => 'candidate_id', 'year' => 'year', 'office' => 'office_id'), 'bill'),
|
| 128 |
);
|
| 129 |
|
| 130 |
$lists['bills_by_candidate_category_office'] = array(
|
| 131 |
'description' => t('Votes by official, year and office'),
|
| 132 |
'table' => 'bill',
|
| 133 |
'votesmart' => array('Votes.getBillsByOfficialYearOffice', array('candidateId' => 'candidate_id', 'year' => 'year', 'office' => 'office_id'), 'bill'),
|
| 134 |
);
|
| 135 |
|
| 136 |
if ($filter) {
|
| 137 |
$ret = array();
|
| 138 |
foreach ($filter as $list) {
|
| 139 |
$ret[$list] = $lists[$list];
|
| 140 |
}
|
| 141 |
return $ret;
|
| 142 |
}
|
| 143 |
|
| 144 |
return $lists;
|
| 145 |
}
|
| 146 |
|
| 147 |
function _votesmart_tables($filter = array()) {
|
| 148 |
if ($filter && !is_array($filter)) $filter = array($filter);
|
| 149 |
$tables = array();
|
| 150 |
$tables['address'] = array(
|
| 151 |
);
|
| 152 |
$tables['measure'] = array(
|
| 153 |
'description' => t('Measure'),
|
| 154 |
'votesmart' => array('Measure.getMeasure', array('measureId' => 'measure_id'), 'measure'),
|
| 155 |
'fields' => array(
|
| 156 |
'measure_id' => array(
|
| 157 |
'type' => 'integer',
|
| 158 |
'description' => t('Measure'),
|
| 159 |
'votesmart' => 'measureId',
|
| 160 |
),
|
| 161 |
'measure_code' => array(
|
| 162 |
'type' => 'varchar',
|
| 163 |
'length' => 100,
|
| 164 |
'description' => t('Measure code'),
|
| 165 |
'votesmart' => 'measureCode',
|
| 166 |
),
|
| 167 |
'title' => array(
|
| 168 |
'type' => 'varchar',
|
| 169 |
'length' => 200,
|
| 170 |
'description' => t('Title'),
|
| 171 |
'votesmart' => 'title',
|
| 172 |
),
|
| 173 |
'election_date' => array(
|
| 174 |
'type' => 'varchar',
|
| 175 |
'length' => 200,
|
| 176 |
'description' => t('Election date'),
|
| 177 |
'votesmart' => 'electionDate',
|
| 178 |
),
|
| 179 |
'election_type' => array(
|
| 180 |
'type' => 'varchar',
|
| 181 |
'length' => 200,
|
| 182 |
'description' => t('Election type'),
|
| 183 |
'votesmart' => 'electionType',
|
| 184 |
),
|
| 185 |
'source' => array(
|
| 186 |
'type' => 'varchar',
|
| 187 |
'length' => 200,
|
| 188 |
'description' => t('Source'),
|
| 189 |
'votesmart' => 'source',
|
| 190 |
),
|
| 191 |
'url' => array(
|
| 192 |
'type' => 'varchar',
|
| 193 |
'length' => 200,
|
| 194 |
'description' => t('URL'),
|
| 195 |
'votesmart' => 'url',
|
| 196 |
),
|
| 197 |
'summary' => array(
|
| 198 |
'type' => 'long',
|
| 199 |
'description' => t('Summary'),
|
| 200 |
'votesmart' => 'summary',
|
| 201 |
),
|
| 202 |
'summary_url' => array(
|
| 203 |
'type' => 'varchar',
|
| 204 |
'length' => 200,
|
| 205 |
'description' => t('Summary URL'),
|
| 206 |
'votesmart' => 'summaryUrl',
|
| 207 |
),
|
| 208 |
'body' => array(
|
| 209 |
'type' => 'long',
|
| 210 |
'description' => t('Measure text'),
|
| 211 |
'votesmart' => 'measureText',
|
| 212 |
),
|
| 213 |
'text_url' => array(
|
| 214 |
'type' => 'varchar',
|
| 215 |
'length' => 200,
|
| 216 |
'description' => t('Text URL'),
|
| 217 |
'votesmart' => 'textUrl',
|
| 218 |
),
|
| 219 |
'pro_url' => array(
|
| 220 |
'type' => 'varchar',
|
| 221 |
'length' => 200,
|
| 222 |
'description' => t('Pro URL'),
|
| 223 |
'votesmart' => 'proUrl',
|
| 224 |
),
|
| 225 |
'con_url' => array(
|
| 226 |
'type' => 'varchar',
|
| 227 |
'length' => 200,
|
| 228 |
'description' => t('Con URL'),
|
| 229 |
'votesmart' => 'conUrl',
|
| 230 |
),
|
| 231 |
'yes' => array(
|
| 232 |
'type' => 'integer',
|
| 233 |
'description' => t('Yes'),
|
| 234 |
'votesmart' => 'yes',
|
| 235 |
),
|
| 236 |
'no' => array(
|
| 237 |
'type' => 'integer',
|
| 238 |
'description' => t('No'),
|
| 239 |
'votesmart' => 'no',
|
| 240 |
),
|
| 241 |
'outcome' => array(
|
| 242 |
'type' => 'varchar',
|
| 243 |
'length' => 200,
|
| 244 |
'description' => t('Outcome'),
|
| 245 |
'votesmart' => 'outcome',
|
| 246 |
),
|
| 247 |
),
|
| 248 |
);
|
| 249 |
$tables['bill'] = array(
|
| 250 |
'description' => t('Bill'),
|
| 251 |
'votesmart' => array('Votes.getBill', array('billId' => 'bill_id'), 'bill'),
|
| 252 |
);
|
| 253 |
$tables['bill_vote'] = array(
|
| 254 |
'description' => t('Bill Action'),
|
| 255 |
'votesmart' => array('Votes.getBillActionVotes', array('actionId' => 'action_id'), 'vote'),
|
| 256 |
);
|
| 257 |
$tables['candidate'] = array(
|
| 258 |
'description' => t('Candidate'),
|
| 259 |
'votesmart' => array('CandidateBio.getBio', array('candidateId' => 'candidate_id'), 'candidate'),
|
| 260 |
'fields' => array(
|
| 261 |
'candidate_id' => array(
|
| 262 |
'type' => 'integer',
|
| 263 |
'description' => t('Candidate'),
|
| 264 |
'votesmart' => 'candidateId',
|
| 265 |
),
|
| 266 |
'fecid' => array(
|
| 267 |
'type' => 'varchar',
|
| 268 |
'size' => 100,
|
| 269 |
'description' => t('Federal Election Comission ID'),
|
| 270 |
'votesmart' => 'fecid',
|
| 271 |
),
|
| 272 |
'first_name' => array(
|
| 273 |
'type' => 'varchar',
|
| 274 |
'size' => 100,
|
| 275 |
'description' => t('First name'),
|
| 276 |
'votesmart' => 'firstName',
|
| 277 |
),
|
| 278 |
'middle_name' => array(
|
| 279 |
'type' => 'varchar',
|
| 280 |
'size' => 100,
|
| 281 |
'description' => t('Middle name'),
|
| 282 |
'votesmart' => 'middleName',
|
| 283 |
),
|
| 284 |
'last_name' => array(
|
| 285 |
'type' => 'varchar',
|
| 286 |
'size' => 100,
|
| 287 |
'description' => t('Last name'),
|
| 288 |
'votesmart' => 'lastName',
|
| 289 |
),
|
| 290 |
'suffix' => array(
|
| 291 |
'type' => 'varchar',
|
| 292 |
'size' => 10,
|
| 293 |
'description' => t('Suffix'),
|
| 294 |
'votesmart' => 'suffix',
|
| 295 |
),
|
| 296 |
'birth_date' => array(
|
| 297 |
'type' => 'date',
|
| 298 |
'description' => t('Birth date'),
|
| 299 |
'votesmart' => 'birthDate',
|
| 300 |
),
|
| 301 |
'birth_place' => array(
|
| 302 |
'type' => 'varchar',
|
| 303 |
'size' => 100,
|
| 304 |
'description' => t('Birth place'),
|
| 305 |
'votesmart' => 'birthPlace',
|
| 306 |
),
|
| 307 |
'pronounciation' => array(
|
| 308 |
'type' => 'varchar',
|
| 309 |
'size' => 100,
|
| 310 |
'description' => t('Pronounciation'),
|
| 311 |
'votesmart' => 'pronounciation',
|
| 312 |
),
|
| 313 |
'gender' => array(
|
| 314 |
'type' => 'varchar',
|
| 315 |
'size' => 6,
|
| 316 |
'description' => t('Gender'),
|
| 317 |
'votesmart' => 'gender',
|
| 318 |
),
|
| 319 |
'family' => array(
|
| 320 |
'type' => 'varchar',
|
| 321 |
'size' => 100,
|
| 322 |
'description' => t('Family'),
|
| 323 |
'votesmart' => 'family',
|
| 324 |
'callback' => '_votesmart_split_newline',
|
| 325 |
),
|
| 326 |
'home_city' => array(
|
| 327 |
'type' => 'varchar',
|
| 328 |
'size' => 100,
|
| 329 |
'description' => t('Home city'),
|
| 330 |
'votesmart' => 'homeCity',
|
| 331 |
),
|
| 332 |
'home_state' => array(
|
| 333 |
'type' => 'varchar',
|
| 334 |
'size' => 2,
|
| 335 |
'description' => t('Home state'),
|
| 336 |
'votesmart' => 'homeState',
|
| 337 |
),
|
| 338 |
'education' => array(
|
| 339 |
'type' => 'varchar',
|
| 340 |
'size' => 100,
|
| 341 |
'description' => t('Education'),
|
| 342 |
'votesmart' => 'education',
|
| 343 |
'callback' => '_votesmart_split_newline',
|
| 344 |
),
|
| 345 |
'profession' => array(
|
| 346 |
'type' => 'varchar',
|
| 347 |
'size' => 100,
|
| 348 |
'description' => t('Profession'),
|
| 349 |
'votesmart' => 'profession',
|
| 350 |
'callback' => '_votesmart_split_newline',
|
| 351 |
),
|
| 352 |
'political' => array(
|
| 353 |
'type' => 'varchar',
|
| 354 |
'size' => 100,
|
| 355 |
'description' => t('Political'),
|
| 356 |
'votesmart' => 'political',
|
| 357 |
'callback' => '_votesmart_split_newline',
|
| 358 |
),
|
| 359 |
'religion' => array(
|
| 360 |
'type' => 'varchar',
|
| 361 |
'size' => 100,
|
| 362 |
'description' => t('Religion'),
|
| 363 |
'votesmart' => 'religion',
|
| 364 |
),
|
| 365 |
'cong_membership' => array(
|
| 366 |
'type' => 'varchar',
|
| 367 |
'size' => 100,
|
| 368 |
'description' => t('Congressional membership'),
|
| 369 |
'votesmart' => 'congMembership',
|
| 370 |
'callback' => '_votesmart_split_newline',
|
| 371 |
),
|
| 372 |
'org_membership' => array(
|
| 373 |
'type' => 'varchar',
|
| 374 |
'size' => 100,
|
| 375 |
'description' => t('Organizational membership'),
|
| 376 |
'votesmart' => 'orgMembership',
|
| 377 |
'callback' => '_votesmart_split_newline',
|
| 378 |
),
|
| 379 |
'special_message' => array(
|
| 380 |
'type' => 'text',
|
| 381 |
'description' => t('Special message'),
|
| 382 |
'votesmart' => 'specialMsg',
|
| 383 |
),
|
| 384 |
|
| 385 |
// These fields are not defined in the candidate record but in other
|
| 386 |
// queries, such as elections, etc. Perhaps we move them, or otherwise
|
| 387 |
// Indicate the relationship. For now, you're expected to populate them
|
| 388 |
// manually ( without tokens ), and/or through an import script.
|
| 389 |
'election_year' => array(
|
| 390 |
'type' => 'int',
|
| 391 |
'description' => t('Election Year'),
|
| 392 |
'callback' => '_votesmart_split_newline',
|
| 393 |
),
|
| 394 |
'state' => array(
|
| 395 |
'type' => 'char',
|
| 396 |
'size' => 2,
|
| 397 |
'description' => t('State'),
|
| 398 |
'geo_type' => 'polygon',
|
| 399 |
'callback' => '_votesmart_split_newline',
|
| 400 |
),
|
| 401 |
'party' => array(
|
| 402 |
'type' => 'int',
|
| 403 |
'description' => t('Party'),
|
| 404 |
'callback' => '_votesmart_split_newline',
|
| 405 |
),
|
| 406 |
'congressional_district' => array(
|
| 407 |
'type' => 'int',
|
| 408 |
'geo_type' => 'polygon',
|
| 409 |
'description' => t('Congressional district'),
|
| 410 |
),
|
| 411 |
'upper_district' => array(
|
| 412 |
'type' => 'varchar',
|
| 413 |
'size' => '5',
|
| 414 |
'geo_type' => 'polygon',
|
| 415 |
'description' => t('State senate district'),
|
| 416 |
),
|
| 417 |
'lower_district' => array(
|
| 418 |
'type' => 'varchar',
|
| 419 |
'size' => '5',
|
| 420 |
'geo_type' => 'polygon',
|
| 421 |
'description' => t('State house district'),
|
| 422 |
),
|
| 423 |
),
|
| 424 |
);
|
| 425 |
$tables['committee'] = array(
|
| 426 |
);
|
| 427 |
$tables['district'] = array(
|
| 428 |
);
|
| 429 |
$tables['election'] = array(
|
| 430 |
'description' => t('Election'),
|
| 431 |
'votesmart' => array('Election.getElection', array('electionId' => 'election_id')),
|
| 432 |
'fields' => array(
|
| 433 |
'election_id' => array(
|
| 434 |
'type' => 'integer',
|
| 435 |
'description' => t('Election'),
|
| 436 |
'votesmart' => 'electionId',
|
| 437 |
),
|
| 438 |
'name' => array(
|
| 439 |
'type' => 'varchar',
|
| 440 |
'length' => 200,
|
| 441 |
'description' => t('Election name'),
|
| 442 |
'votesmart' => 'name',
|
| 443 |
),
|
| 444 |
'state' => array(
|
| 445 |
'type' => 'varchar',
|
| 446 |
'length' => 2,
|
| 447 |
'description' => t('State'),
|
| 448 |
'votesmart' => 'stateId',
|
| 449 |
),
|
| 450 |
'office_type' => array(
|
| 451 |
'type' => 'integer',
|
| 452 |
'description' => t('Office type'),
|
| 453 |
'votesmart' => 'officeTypeId',
|
| 454 |
'votesmart_list' => 'office_types',
|
| 455 |
),
|
| 456 |
'special' => array(
|
| 457 |
'type' => 'integer',
|
| 458 |
'description' => t('Special election'),
|
| 459 |
'votesmart' => 'special',
|
| 460 |
'callback' => '_votesmart_boolean',
|
| 461 |
),
|
| 462 |
'year' => array(
|
| 463 |
'type' => 'integer',
|
| 464 |
'description' => t('Election year'),
|
| 465 |
'votesmart' => 'electionYear',
|
| 466 |
),
|
| 467 |
),
|
| 468 |
);
|
| 469 |
$tables['position'] = array(
|
| 470 |
);
|
| 471 |
$tables['city'] = array(
|
| 472 |
);
|
| 473 |
$tables['county'] = array(
|
| 474 |
);
|
| 475 |
$tables['npat'] = array(
|
| 476 |
);
|
| 477 |
$tables['office'] = array(
|
| 478 |
);
|
| 479 |
$tables['officials'] = array(
|
| 480 |
);
|
| 481 |
$tables['state'] = array(
|
| 482 |
'description' => t('State'),
|
| 483 |
'votesmart' => array('State.getState', array('stateId' => 'state_id'), 'details'),
|
| 484 |
'fields' => array(
|
| 485 |
'state_id' => array(
|
| 486 |
'type' => 'char',
|
| 487 |
'length' => 2,
|
| 488 |
'description' => t('State code'),
|
| 489 |
'votesmart' => 'stateId',
|
| 490 |
),
|
| 491 |
'type' => array(
|
| 492 |
'type' => 'varchar',
|
| 493 |
'length' => 10,
|
| 494 |
'description' => t('State type'),
|
| 495 |
'votesmart' => 'stateType'
|
| 496 |
),
|
| 497 |
'name' => array(
|
| 498 |
'type' => 'varchar',
|
| 499 |
'length' => 100,
|
| 500 |
'description' => t('State'),
|
| 501 |
'votesmart' => 'name'
|
| 502 |
),
|
| 503 |
'nickname' => array(
|
| 504 |
'type' => 'varchar',
|
| 505 |
'length' => 100,
|
| 506 |
'description' => t('Nickname'),
|
| 507 |
'votesmart' => 'nickName'
|
| 508 |
),
|
| 509 |
'capital' => array(
|
| 510 |
'type' => 'varchar',
|
| 511 |
'length' => 200,
|
| 512 |
'description' => t('Capital'),
|
| 513 |
'votesmart' => 'capital'
|
| 514 |
),
|
| 515 |
'area' => array(
|
| 516 |
'type' => 'int',
|
| 517 |
'description' => t('Area'),
|
| 518 |
'votesmart' => 'area',
|
| 519 |
'callback' => '_votesmart_numeric',
|
| 520 |
),
|
| 521 |
'population' => array(
|
| 522 |
'type' => 'int',
|
| 523 |
'description' => t('Population'),
|
| 524 |
'votesmart' => 'population',
|
| 525 |
'callback' => '_votesmart_numeric',
|
| 526 |
),
|
| 527 |
'statehood' => array(
|
| 528 |
'type' => 'varchar',
|
| 529 |
'length' => 200,
|
| 530 |
'description' => t('Statehood'),
|
| 531 |
'votesmart' => 'statehood',
|
| 532 |
'callback' => '_votesmart_date',
|
| 533 |
),
|
| 534 |
'motto' => array(
|
| 535 |
'type' => 'varchar',
|
| 536 |
'length' => 200,
|
| 537 |
'description' => t('Motto'),
|
| 538 |
'votesmart' => 'motto'
|
| 539 |
),
|
| 540 |
'flower' => array(
|
| 541 |
'type' => 'varchar',
|
| 542 |
'length' => 200,
|
| 543 |
'description' => t('Flower'),
|
| 544 |
'votesmart' => 'flower'
|
| 545 |
),
|
| 546 |
'tree' => array(
|
| 547 |
'type' => 'varchar',
|
| 548 |
'length' => 200,
|
| 549 |
'description' => t('Tree'),
|
| 550 |
'votesmart' => 'tree'
|
| 551 |
),
|
| 552 |
'bird' => array(
|
| 553 |
'type' => 'varchar',
|
| 554 |
'length' => 200,
|
| 555 |
'description' => t('Bird'),
|
| 556 |
'votesmart' => 'bird'
|
| 557 |
),
|
| 558 |
'highpoint' => array(
|
| 559 |
'type' => 'varchar',
|
| 560 |
'length' => 200,
|
| 561 |
'description' => t('Highest point'),
|
| 562 |
'votesmart' => 'highPoint'
|
| 563 |
),
|
| 564 |
'lowpoint' => array(
|
| 565 |
'type' => 'varchar',
|
| 566 |
'length' => 200,
|
| 567 |
'description' => t('Lowest point'),
|
| 568 |
'votesmart' => 'lowPoint'
|
| 569 |
),
|
| 570 |
'bicameral' => array(
|
| 571 |
'type' => 'varchar',
|
| 572 |
'description' => t('Bicameral legislature'),
|
| 573 |
'votesmart' => 'bicameral',
|
| 574 |
'callback' => '_votesmart_boolean',
|
| 575 |
),
|
| 576 |
'upper_legislature' => array(
|
| 577 |
'type' => 'varchar',
|
| 578 |
'length' => 200,
|
| 579 |
'description' => t('Upper legislature'),
|
| 580 |
'votesmart' => 'upperLegis'
|
| 581 |
),
|
| 582 |
'lower_legislature' => array(
|
| 583 |
'type' => 'varchar',
|
| 584 |
'length' => 200,
|
| 585 |
'description' => t('Lower legislature'),
|
| 586 |
'votesmart' => 'lowerLegis'
|
| 587 |
),
|
| 588 |
'leutenant_gov' => array(
|
| 589 |
'type' => 'varchar',
|
| 590 |
'length' => 200,
|
| 591 |
'description' => t('Leutenant governor'),
|
| 592 |
'votesmart' => 'ltGov',
|
| 593 |
'callback' => '_votesmart_boolean',
|
| 594 |
),
|
| 595 |
'senators' => array(
|
| 596 |
'type' => 'integer',
|
| 597 |
'description' => t('Senators'),
|
| 598 |
'votesmart' => 'senators'
|
| 599 |
),
|
| 600 |
'reps' => array(
|
| 601 |
'type' => 'integer',
|
| 602 |
'description' => t('Representatives'),
|
| 603 |
'votesmart' => 'reps'
|
| 604 |
),
|
| 605 |
'term_limit' => array(
|
| 606 |
'type' => 'integer',
|
| 607 |
'description' => t('Term limit'),
|
| 608 |
'votesmart' => 'termLimit'
|
| 609 |
),
|
| 610 |
'term_length' => array(
|
| 611 |
'type' => 'varchar',
|
| 612 |
'length' => 200,
|
| 613 |
'description' => t('Term length'),
|
| 614 |
'votesmart' => 'termLength'
|
| 615 |
),
|
| 616 |
'bill_url' => array(
|
| 617 |
'type' => 'varchar',
|
| 618 |
'length' => 255,
|
| 619 |
'description' => t('Bill URL'),
|
| 620 |
'votesmart' => 'billUrl'
|
| 621 |
),
|
| 622 |
'vote_url' => array(
|
| 623 |
'type' => 'varchar',
|
| 624 |
'length' => 200,
|
| 625 |
'description' => t('Vote URL'),
|
| 626 |
'votesmart' => 'voteUrl'
|
| 627 |
),
|
| 628 |
'voter_registration' => array(
|
| 629 |
'type' => 'long',
|
| 630 |
'description' => t('Voter registration'),
|
| 631 |
'votesmart' => 'voterReg'
|
| 632 |
),
|
| 633 |
'primary_date' => array(
|
| 634 |
'type' => 'varchar',
|
| 635 |
'length' => 200,
|
| 636 |
'description' => t('Primary election'),
|
| 637 |
'votesmart' => 'primaryDate'
|
| 638 |
),
|
| 639 |
'general_date' => array(
|
| 640 |
'type' => 'varchar',
|
| 641 |
'length' => 200,
|
| 642 |
'description' => t('General election'),
|
| 643 |
'votesmart' => 'generalDate'
|
| 644 |
),
|
| 645 |
'absentee_who' => array(
|
| 646 |
'type' => 'varchar',
|
| 647 |
'length' => 200,
|
| 648 |
'votesmart' => 'absenteeWho'
|
| 649 |
),
|
| 650 |
'absentee_how' => array(
|
| 651 |
'type' => 'varchar',
|
| 652 |
'length' => 200,
|
| 653 |
'votesmart' => 'absenteeHow'
|
| 654 |
),
|
| 655 |
'absentee_when' => array(
|
| 656 |
'type' => 'varchar',
|
| 657 |
'length' => 200,
|
| 658 |
'votesmart' => 'absenteeWhen'
|
| 659 |
),
|
| 660 |
'largest_city' => array(
|
| 661 |
'type' => 'varchar',
|
| 662 |
'length' => 255,
|
| 663 |
'description' => t('Largest city'),
|
| 664 |
'votesmart' => 'largestCity'
|
| 665 |
),
|
| 666 |
'roll_upper' => array(
|
| 667 |
'type' => 'varchar',
|
| 668 |
'length' => 100,
|
| 669 |
'votesmart' => 'rollUpper'
|
| 670 |
),
|
| 671 |
'roll_lower' => array(
|
| 672 |
'type' => 'varchar',
|
| 673 |
'length' => 200,
|
| 674 |
'votesmart' => 'rollLower'
|
| 675 |
),
|
| 676 |
'us_circuit' => array(
|
| 677 |
'type' => 'varchar',
|
| 678 |
'length' => 200,
|
| 679 |
'description' => t('U.S. circuit'),
|
| 680 |
'votesmart' => 'usCircuit'
|
| 681 |
),
|
| 682 |
),
|
| 683 |
);
|
| 684 |
$tables['sig'] = array(
|
| 685 |
'description' => t('Special interest group'),
|
| 686 |
'votesmart' => array('Rating.getSig', array('sigId' => 'sig_id')),
|
| 687 |
'fields' => array(
|
| 688 |
'sig_id' => array(
|
| 689 |
'type' => 'integer',
|
| 690 |
'description' => t('Special interest group id'),
|
| 691 |
'votesmart' => 'sigId'
|
| 692 |
),
|
| 693 |
'parent_id' => array(
|
| 694 |
'type' => 'integer',
|
| 695 |
'description' => t('Special interest group parent'),
|
| 696 |
'votesmart' => 'parentId'
|
| 697 |
),
|
| 698 |
'state_id' => array(
|
| 699 |
'type' => 'char',
|
| 700 |
'length' => 2,
|
| 701 |
'description' => t('State'),
|
| 702 |
'votesmart' => 'stateId',
|
| 703 |
),
|
| 704 |
'name' => array(
|
| 705 |
'type' => 'name',
|
| 706 |
'length' => 200,
|
| 707 |
'description' => t('Name'),
|
| 708 |
'votesmart' => 'name',
|
| 709 |
),
|
| 710 |
'description' => array(
|
| 711 |
'type' => 'long',
|
| 712 |
'description' => t('Description'),
|
| 713 |
'votesmart' => 'description',
|
| 714 |
),
|
| 715 |
'address' => array(
|
| 716 |
'type' => 'varchar',
|
| 717 |
'length' => 255,
|
| 718 |
'description' => t('Address'),
|
| 719 |
'votesmart' => 'address',
|
| 720 |
),
|
| 721 |
'city' => array(
|
| 722 |
'type' => 'varchar',
|
| 723 |
'length' => 255,
|
| 724 |
'description' => t('City'),
|
| 725 |
'votesmart' => 'city',
|
| 726 |
),
|
| 727 |
'state' => array(
|
| 728 |
'type' => 'varchar',
|
| 729 |
'length' => 2,
|
| 730 |
'description' => t('State'),
|
| 731 |
'votesmart' => 'state',
|
| 732 |
),
|
| 733 |
'zip' => array(
|
| 734 |
'type' => 'varchar',
|
| 735 |
'length' => 10,
|
| 736 |
'description' => t('Zip'),
|
| 737 |
'votesmart' => 'zip',
|
| 738 |
),
|
| 739 |
'phone1' => array(
|
| 740 |
'type' => 'varchar',
|
| 741 |
'length' => 10,
|
| 742 |
'description' => t('Phone number'),
|
| 743 |
'votesmart' => 'phone1',
|
| 744 |
),
|
| 745 |
'phone2' => array(
|
| 746 |
'type' => 'varchar',
|
| 747 |
'length' => 10,
|
| 748 |
'description' => t('Additional phone number'),
|
| 749 |
'votesmart' => 'phone2',
|
| 750 |
),
|
| 751 |
'fax' => array(
|
| 752 |
'type' => 'varchar',
|
| 753 |
'length' => 10,
|
| 754 |
'description' => t('Fax'),
|
| 755 |
'votesmart' => 'fax',
|
| 756 |
),
|
| 757 |
'email' => array(
|
| 758 |
'type' => 'varchar',
|
| 759 |
'length' => 200,
|
| 760 |
'description' => t('E-mail'),
|
| 761 |
'votesmart' => 'email',
|
| 762 |
),
|
| 763 |
'url' => array(
|
| 764 |
'type' => 'varchar',
|
| 765 |
'length' => 200,
|
| 766 |
'description' => t('URL'),
|
| 767 |
'votesmart' => 'url',
|
| 768 |
),
|
| 769 |
'contact_name' => array(
|
| 770 |
'type' => 'varchar',
|
| 771 |
'length' => 200,
|
| 772 |
'description' => t('Contact name'),
|
| 773 |
'votesmart' => 'contactName',
|
| 774 |
),
|
| 775 |
),
|
| 776 |
);
|
| 777 |
$tables['rating'] = array(
|
| 778 |
);
|
| 779 |
$tables['vote'] = array(
|
| 780 |
);
|
| 781 |
|
| 782 |
if ($filter) {
|
| 783 |
$ret = array();
|
| 784 |
foreach ($filter as $table) {
|
| 785 |
$ret[$table] = $tables[$table];
|
| 786 |
}
|
| 787 |
return $ret;
|
| 788 |
}
|
| 789 |
|
| 790 |
return $tables;
|
| 791 |
}
|
| 792 |
|
| 793 |
/**
|
| 794 |
* Basic value conversion functions.
|
| 795 |
*/
|
| 796 |
function _votesmart_numeric($value) {
|
| 797 |
return (preg_replace('/[^\d.]/', '', $value));
|
| 798 |
}
|
| 799 |
|
| 800 |
function _votesmart_boolean($value) {
|
| 801 |
return ($value == 't');
|
| 802 |
}
|
| 803 |
|
| 804 |
function _votesmart_date($value) {
|
| 805 |
}
|
| 806 |
|
| 807 |
function _votesmart_split_newline($value) {
|
| 808 |
return (explode("\n", $value));
|
| 809 |
}
|