Skip to content

Commit

Permalink
Resolves #1 - Rename update* to parse*
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofMadejski committed Nov 7, 2017
1 parent e9e807e commit 3b9646b
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/Senat.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ private function _senatorExtractSenatAssemblies($html) {
return $this->__senatorExtractTeams($html, '<p class="etykieta">Zespoły senackie</p>', '</ul>');
}

public function updateSenatorSpeechesList($SenatorID, $chamberInt) {
public function parseSenatorSpeechesList($SenatorID, $chamberInt) {
$html = $this->curl_get(self::BASE_URL . '/sklad/senatorowie/aktywnosc,' . $SenatorID . ',' . $chamberInt . '.html');

$re = "/<tr>[^<]*?<td class=\"numer-posiedzenia\">([\\d]*?)<\\/td>[\\s\\S]*?<td class=\"data-aktywnosci nowrap\">([^<]*?)<\\/td>[^<]*?<td class=\"punkt\">([^<]*?)<\\/td>[^<]*?<td class=\"etapy\">([\\s\\S]*?)<\\/td>[^<]*?<\\/tr>/";
Expand Down Expand Up @@ -567,7 +567,7 @@ public function urlSittingStenogram($id_sitting_with_day) {
return self::BASE_URL . '/prace/senat/posiedzenia/przebieg,' . $id_sitting_with_day . '.html';
}

public function updateSenatorVotesAtMeeting($SenatorID, $MeetingID) {
public function parseSenatorVotesAtMeeting($SenatorID, $MeetingID) {
$html = $this->curl_get(self::BASE_URL . '/sklad/senatorowie/aktywnosc-glosowania,' . $SenatorID . ',8,szczegoly,' . $MeetingID . '.html');

$re = "/<td>[^<]*?<a href=\"(\\/sklad\\/senatorowie\\/szczegoly-glosowania,([^,]*),([^,]*),8.html)\">[^<]*?<\\/a>[^<]*?<\\/td>[^<]*?<td>[^<]*?<\\/td>[^<]*?<td>([^<]*)<\\/td>/";
Expand All @@ -587,7 +587,7 @@ public function updateSenatorVotesAtMeeting($SenatorID, $MeetingID) {
}

//Vote might me: za/przeciw/wstrzymał się/nie głosował/nieobecny
public function updateSenatorVotingActivity($SenatorID) {
public function parseSenatorVotingActivity($SenatorID) {
$html = $this->curl_get(self::BASE_URL . '/sklad/senatorowie/aktywnosc-glosowania,' . $SenatorID . ',8.html');

$re = "/<td class=\"nowrap\">[^<]*?<a href=\"(\\/sklad\\/senatorowie\\/aktywnosc-glosowania,[\\d]*,8,szczegoly,([^.]*)\\.html)\">[^<]*?<\\/a>[^<]*?<\\/td>/";
Expand All @@ -598,7 +598,7 @@ public function updateSenatorVotingActivity($SenatorID) {

$ans = array();
foreach ($matches as $match) {
$ans[$match[2]] = $this->updateSenatorVotesAtMeeting($SenatorID, $match[2]);
$ans[$match[2]] = $this->parseSenatorVotesAtMeeting($SenatorID, $match[2]);
}
return $ans;
}
Expand All @@ -608,8 +608,7 @@ public function updateSenatorVotingActivity($SenatorID) {
* @param $chamberNo Poczynając od IX kadencji na stronach Senatu zaczęto aggregować archiwalne informacje
* @return array
*/
// TODO rename update to parse
public function updateSenatorInfo($SenatorID, $chamberNo) {
public function parseSenatorInfo($SenatorID, $chamberNo) {
$url = self::BASE_URL . '/sklad/senatorowie/senator,' . $SenatorID . ',' . $chamberNo . '.html';
$html = $this->curl_get($url);

Expand All @@ -629,7 +628,7 @@ public function updateSenatorInfo($SenatorID, $chamberNo) {
'committees' => $this->_senatorExtractCommissions($html),
'parliamentary_assemblies' => $this->_senatorExtractParlimentaryAssemblies($html),
'senat_assemblies' => $this->_senatorExtractSenatAssemblies($html),
'activity_senat_meetings' => $this->updateSenatorSpeechesList($SenatorID, $chamberNo),
'activity_senat_meetings' => $this->parseSenatorSpeechesList($SenatorID, $chamberNo),
'senator_statements' => self::BASE_URL . '/sklad/senatorowie/oswiadczenia-senatorskie,' . $SenatorID . ',' . $chamberNo . '.html',
'source' => $url
);
Expand All @@ -652,7 +651,7 @@ public function urlSenatorsList() {
* @return array
* @throws ParserException
*/
public function updateSenatorsList($chamberNo = null) {
public function parseSenatorsList($chamberNo = null) {
if ($chamberNo === null) {
$html = $this->curl_get($this->urlSenatorsList());
} else {
Expand Down Expand Up @@ -707,19 +706,19 @@ public function getChecksumForInfo($inArray) {
return md5(json_encode($inArray));
}

public function updateSenatorsAll() {
$list = $this->updateSenatorsList();
public function parseSenatorsAll() {
$list = $this->parseSenatorsList();

foreach ($list as &$senator) {
$senator['info'] = $this->updateSenatorInfo($senator['id']);
$senator['info'] = $this->parseSenatorInfo($senator['id']);
}

return $list;
}

/**
* This will extract one speech from stenogram (from ::updateMeetingStenogram method), using given $speechRel.
* @param string $meetingTxt Output of ::updateMeetingStenogram
* This will extract one speech from stenogram (from ::parseMeetingStenogram method), using given $speechRel.
* @param string $meetingTxt Output of ::parseMeetingStenogram
* @param string $speechRel Speech rel of Senator`s speech.
* @param bool $removeMarszalekEtc When true (default) it will try to remove speeches of Marszałek and Wicemarszałek (as it would be introduce to next speech).
* @return string
Expand Down Expand Up @@ -778,7 +777,7 @@ public function getStenogram($id_sitting_with_day) {
* @param string $meetingID Meeting ID.
* @return string Text, witouh double spaces, HTML etc.
*/
public function updateMeetingStenogram($meetingID) {
public function parseMeetingStenogram($meetingID) {
$text = "\r\n";
$i = 0;
do {
Expand Down Expand Up @@ -809,7 +808,7 @@ public function updateMeetingStenogram($meetingID) {
}

// http://senat.gov.pl/prace/senat/posiedzenia/glosowanie-drukuj,368.html
public function updatePeopleVotes($url) {
public function parsePeopleVotes($url) {
$html = $this->curl_get($url);
$dom = str_get_html($html);

Expand Down Expand Up @@ -891,7 +890,7 @@ public function urlMeetingsVotings($meetingID, $i) {
return self::BASE_URL . '/prace/senat/posiedzenia/przebieg,' . $source_ids[0] . ',' . $i . ',glosowania.html';
}

public function updateMeetingVotings($meetingID) {
public function parseMeetingVotings($meetingID) {
$ans = array();

$i = 0;
Expand Down Expand Up @@ -955,7 +954,7 @@ public function updateMeetingVotings($meetingID) {
* This will return list of all meetings
* @return array ['id'=>ID of meeting, 'name'=>Name/title/subject of meeting. 'when'=>Date(s) of meeting(s)]
*/
public function updateMeetingsList() {
public function parseMeetingsList() {
$answer = array();

$i = 0;
Expand Down

0 comments on commit 3b9646b

Please sign in to comment.