/[drupal]/contributions/modules/legislature/imports/us/thomas.inc
ViewVC logotype

Diff of /contributions/modules/legislature/imports/us/thomas.inc

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

revision 1.4, Mon Jun 16 20:23:25 2008 UTC revision 1.5, Tue Jun 17 01:11:51 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: thomas.inc,v 1.3 2008/06/16 20:16:29 drumm Exp $  // $Id: thomas.inc,v 1.4 2008/06/16 20:23:25 drumm Exp $
3    
4  /**  /**
5   * @file Parse committees from Thomas, House, and Senate websites.   * @file Parse committees from Thomas, House, and Senate websites.
# Line 25  function legislature_us_thomas_committee Line 25  function legislature_us_thomas_committee
25        $subcommittee_id = $matches[4][$key];        $subcommittee_id = $matches[4][$key];
26    
27        if ($subcommittee_id == 0) {        if ($subcommittee_id == 0) {
28          $committees[$chamber . $id][$session]['thomasname'] = $name;          $committees[$chamber . $id][$session]['thomas_name'] = $name;
29        }        }
30        else {        else {
31          $committees[$chamber . $id][$session]['subcommittees'][$subcommittee_id]['thomasname'] = $name;          $committees[$chamber . $id][$session]['subcommittees'][$subcommittee_id]['thomas_name'] = $name;
32        }        }
33      }      }
34    }    }
# Line 68  function legislature_us_thomas_committee Line 68  function legislature_us_thomas_committee
68      if (preg_match('/<span class="contenttext"><a href="(http:\/\/.*?senate.gov\/.*?)">/', $html, $matches2)) {      if (preg_match('/<span class="contenttext"><a href="(http:\/\/.*?senate.gov\/.*?)">/', $html, $matches2)) {
69        $committees[$code]['url'] = $matches2[1];        $committees[$code]['url'] = $matches2[1];
70      }      }
71      if (isset($committees[$code][$session]['thomasname'])) {  
       $thomasname = $type .' '. $committees[$code][$session]['thomasname'];  
     }  
     else {  
       $thomasname = $display_name;  
     }  
     /* todo  
     my $cxml = AddXmlNode($xml->documentElement, 'committee', type => lc($type), code => $code, displayname => $display_name);  
     AddCommitteeNames($cxml, $code);  
     DBInsert(committees, id => $code, type => lc($type), displayname => $display_name, thomasname => $thomasname, url => $url)  
     */  
72      $subcommittee_code = $code;      $subcommittee_code = $code;
73      $subcommittee_id = NULL;      $subcommittee_id = NULL;
74      $subcommittee_name = NULL;      $subcommittee_name = NULL;
# Line 98  function legislature_us_thomas_committee Line 88  function legislature_us_thomas_committee
88          $subcommittee_count += 1;          $subcommittee_count += 1;
89          $subcommittee_name = preg_replace('/^(Permanent )?Subcommittee on /', '', $matches2[1]);          $subcommittee_name = preg_replace('/^(Permanent )?Subcommittee on /', '', $matches2[1]);
90          $subcommittee_name = preg_replace('/  /', ' ', $subcommittee_name);          $subcommittee_name = preg_replace('/  /', ' ', $subcommittee_name);
91          $subcommittee_thomasname = $committees[$code][$session]['subcommittees'][$subcommittee_id]['thomasname'];          $subcommittee_thomasname = $committees[$code][$session]['subcommittees'][$subcommittee_id]['thomas_name'];
92          $committees[$code][$session]['subcommittees'][$subcommittee_id]['display name'] = $subcommittee_name;          $committees[$code][$session]['subcommittees'][$subcommittee_id]['display name'] = $subcommittee_name;
93          if ($subcommittee_thomasname == '') {          if ($subcommittee_thomasname == '') {
94            $subcommittee_thomasname = $subname;            $subcommittee_thomasname = $subname;
95          }          }
         /* todo  
         $scxml = AddXmlNode($cxml, 'subcommittee', code => $subid, displayname => $subname);  
         AddCommitteeNames($scxml, $code, $subid);  
         DBInsert(committees, id => $subcode, parent => $code, displayname => $subname, thomasname => $thomasnamesub)  
         */  
96          continue;          continue;
97        }        }
98        if (preg_match('/<pub_last>(.*)<\/pub_last>, <pub_first>(.*)<\/pub_first> \(<state>(.*)<\/state>\)(, <position>(.*)<\/position>)?/', $line, $matches2)) {        if (preg_match('/<pub_last>(.*)<\/pub_last>, <pub_first>(.*)<\/pub_first> \(<state>(.*)<\/state>\)(, <position>(.*)<\/position>)?/', $line, $matches2)) {
# Line 190  function legislature_us_thomas_committee Line 175  function legislature_us_thomas_committee
175      if (isset($translate_code[$house_code])) {      if (isset($translate_code[$house_code])) {
176        $our_code = $translate_code[$house_code];        $our_code = $translate_code[$house_code];
177      }      }
     $thomasname = $committees[$our_code][$session]['thomasname'];  
     if ($thomasname == '') {  
       watchdog('legislature', t('FEC committees: Thomas name not found for %code', array('%code' => $our_code)));  
     }  
178      if (!isset($committees[$our_code]['covered'])) {      if (!isset($committees[$our_code]['covered'])) {
179        $committees[$our_code]['covered'] = TRUE;        $committees[$our_code]['covered'] = TRUE;
180        $committees[$our_code]['display name'] = $display_name;        $committees[$our_code]['display name'] = $display_name;
       if ($thomasname == '') {  
         $thomasname = '';  
       }  
       else {  
         $thomasname = $type .' '. $thomasname;  
       }  
       /* todo  
       $cxml = AddXmlNode($xml->documentElement, 'committee',  
         type => lc($type), code => $ourcode, displayname => $display_name);  
       AddCommitteeNames($cxml, $ourcode);  
       DBInsert(committees, id => $ourcode, type => lc($type), displayname => $display_name, thomasname => $thomasname, url => undef) if (!$testing);  
       */  
181      }      }
182      else {      else {
183        // this is joint committee already imported by the senate        // this is joint committee already imported by the senate
# Line 239  function legislature_us_thomas_committee Line 208  function legislature_us_thomas_committee
208          $html = $response->data;          $html = $response->data;
209          $code = $our_code . $subcommittee_id;          $code = $our_code . $subcommittee_id;
210          $subcommittee_name = $subcommittee_names[$subcommittee_id];          $subcommittee_name = $subcommittee_names[$subcommittee_id];
211          $subcommittee_thomasname = $committees[$our_code][$session]['subcommittees'][$subcommittee_id]['thomasname'];          $subcommittee_thomasname = $committees[$our_code][$session]['subcommittees'][$subcommittee_id]['thomas_name'];
212          $committees[$our_code][$session]['subcommittees'][$subcommittee_id]['display name'] = $subcommittee_name;          $committees[$our_code][$session]['subcommittees'][$subcommittee_id]['display name'] = $subcommittee_name;
213          if ($subcommittee_thomasname == '') {          if ($subcommittee_thomasname == '') {
214            $subcommittee_thomasname = $subcommittee_name;            $subcommittee_thomasname = $subcommittee_name;
215          }          }
         /* todo  
         $scxml = AddXmlNode($cxml, 'subcommittee', code => $scid, displayname => $subname);  
         AddCommitteeNames($scxml, $ourcode, $scid);  
         DBInsert(committees, id => "$ourcode$scid", parent => $ourcode, displayname => $subname, thomasname => $thomasnamesub) if (!$testing);  
         */  
216        }        }
217        $state = 0;        $state = 0;
218        $rank = -1;        $rank = -1;
# Line 305  function legislature_us_thomas_committee Line 269  function legislature_us_thomas_committee
269    
270    // Add missing records    // Add missing records
271    // Then add records that we saw on Thomas but not on the Senate/House sites    // Then add records that we saw on Thomas but not on the Senate/House sites
272    // (cause House took ages to update at the start of 2007)    // (cause House took ages to update at the start of 2007). These committees
273      // are obsolete.
274    foreach (array_keys($committees) as $code) {    foreach (array_keys($committees) as $code) {
275      if (isset($committees[$code]['covered'])) {      if (isset($committees[$code]['covered'])) {
276        next;        next;
# Line 318  function legislature_us_thomas_committee Line 283  function legislature_us_thomas_committee
283      }      }
284      $name = '';      $name = '';
285      foreach (legislature_get_enabled_sessions('us') as $session) {      foreach (legislature_get_enabled_sessions('us') as $session) {
286        if (!empty($committees[$code][$session]['thomasname'])) {        if (!empty($committees[$code][$session]['thomas_name'])) {
287          $name = $committees[$code][$session]['thomasname'];          $name = $committees[$code][$session]['thomas_name'];
288        }        }
289      }      }
290      $display_name = $type .' Commitee on '. $name;      $committees[$code]['display name'] = $type .' Committee on '. $name;
     $committees[$code]['display name'] = $display_name;  
     /* todo  
     my $cxml = AddXmlNode($xml->documentElement, 'committee', type => lc($type), code => uc($code), displayname => $displayname);  
     AddCommitteeNames($cxml, uc($code));  
   
     if (!$Committee{$code}{$SESSION}{thomasname}) {  
       $cxml->setAttribute("obsolete", "1");  
     } else {  
       DBInsert(committees, id => uc($code), type => lc($type),  
       displayname => $displayname, thomasname => $Committee{$code}{$SESSION}{thomasname})  
     }  
     */  
291    }    }
292    
293    // Save the committees    // Save the committees
294    foreach ($committees as $committee) {    $offices = array(
295      // Office ID      'h' => 'House',
296      // Session ID      's' => 'Senate',
297      // Display Name    );
298      // URL    foreach ($committees as $code => $committee) {
299        if (isset($offices[$code{0}])) {
300          $office_id = legislature_get_office_id('US', $offices[$code{0}]);
301          foreach (legislature_get_enabled_sessions('us') as $session_name) {
302            if (isset($committee[$session_name])) {
303              $session = legislature_get_session('us', $session_name);
304              $committee_id = legislature_committee($office_id, $session->session_id, $committee['display name'], $committee['url']);
305    
306              // Save Thomas name
307              if (isset($committee[$session_name]['thomas_name'])) {
308                $thomas_name = $offices[$code{0}] .' '. $committee[$session_name]['thomas_name'];
309              }
310              else {
311                $thomas_name = $display_name;
312              }
313              legislature_committee_name($committee_id, $session->session_id, $thomas_name);
314    
315              // Save membership
316    
317              // No, subcommittees are not actually implemented.
318            }
319          }
320        }
321    }    }
322  }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.2