public function awards($compat = TRUE)
{
if (empty($this->awards)) {
$this->getPage("Awards");
$row_s = strpos($this->page["Awards"], '<h1 class="header">Awards</h1>');
$row_e = strpos($this->page["Awards"], '<div class="article"', $row_s);
$block = substr($this->page["Awards"], $row_s, $row_e - $row_s);
preg_match_all('!<h3>\\s*(?<festival>.+?)\\s*<a [^>]+>\\s*(?<year>\\d{4}).*?</h3>\\s*<table [^>]+>(?<table>.+?)</table>!ims', $block, $matches);
$acount = count($matches[0]);
for ($i = 0; $i < $acount; $i++) {
$festival = $matches['festival'][$i];
if (!preg_match_all('!<td class="(?<class>.+?)"[^>]*>\\s*(?<data>.*?)\\s*</td>!ims', $matches['table'][$i], $col)) {
continue;
}
$ccount = count($col[0]);
for ($k = 0; $k < $ccount; ++$k) {
switch ($col['class'][$k]) {
case "title_award_outcome":
$have_title = TRUE;
$have_desc = FALSE;
preg_match('!(?<outcome>.+?)<br\\s*/>\\s*<span class="award_category">\\s*(?<award>.+?)</span>!ims', $col['data'][$k], $data);
$outcome = trim(strip_tags($data['outcome']));
$outcome == "Won" ? $won = TRUE : ($won = FALSE);
$award = trim($data['award']);
break;
case "award_description":
$desc = trim($col['data'][$k]);
if (preg_match_all('|<a href\\="/name/nm(\\d{7})[^"]*"\\s*>(.*?)</a>|s', $desc, $data)) {
$people = isset($data[0][0]) ? array_combine($data[1], $data[2]) : array();
preg_match('!(.+?)<br!ims', $desc, $data) ? $cat = $data[1] : ($cat = '');
if (substr($cat, 0, 3) == '<a ') {
$cat = '';
}
} else {
$desc = preg_replace('#<div class="award_detail_notes">.+?</div>#s', '', $desc);
$cat = trim(strip_tags($desc));
$people = array();
}
if ($compat) {
$this->awards[$festival]['entries'][] = array('year' => $matches['year'][$i], 'won' => $won, 'category' => $cat, 'award' => $award, 'people' => $people, 'comment' => '', 'outcome' => $outcome);
} else {
$this->awards[$festival][] = array('year' => $matches['year'][$i], 'won' => $won, 'category' => $cat, 'award' => $award, 'people' => $people, 'outcome' => $outcome);
}
break;
default:
break;
}
}
continue;
}
}
return $this->awards;
}