function cat_heading($cat_type, $table = true) { global $cats; $row = "<h5>$cat_type. $cats[$cat_type]</h5>"; if ($table) return span_row($row, true); return $row; }
function cat_heading($cat_type, $table = true) { global $cats; $row = "<h3>{$cat_type}. {$cats[$cat_type]}</h3>"; if ($table) { return span_row($row, true); } return $row; }
function register_history($f) { global $dir, $files, $names, $DATA, $PAGE, $link, $this_page; $this_page = 'regmem_diff'; $new = 0; if ($f) { $f = "{$dir}/regmem{$f}.xml"; for ($i = 0; $i < count($files); ++$i) { if ($files[$i] == $f) { $new = $i; break; } } } $old = $new + 1; $old = $files[$old]; $old_iso = preg_replace("#{$dir}/regmem(.*?)\\.xml#", '$1', $old); $old_pretty = format_date($old_iso, LONGDATEFORMAT); $new = $files[$new]; $new_iso = preg_replace("#{$dir}/regmem(.*?)\\.xml#", '$1', $new); $new_pretty = format_date($new_iso, LONGDATEFORMAT); $old = file_get_contents($old); $new = file_get_contents($new); $DATA->set_page_metadata($this_page, 'heading', 'Changes from ' . $old_pretty . ' to ' . $new_pretty); $PAGE->stripe_start(); print $link; $data = array(); parse_file($old, $old_iso, 'old', $data); parse_file($new, $new_iso, 'new', $data); ?> <p>This page shows all the changes in the Register of Members' Interests between the editions of <a href="./?d=<?php echo $old_iso; ?> "><?php echo $old_pretty; ?> </a> and <a href="./?d=<?php echo $new_iso; ?> "><?php echo $new_pretty; ?> </a>, in alphabetical order by MP.</p> <table cellpadding="3" cellspacing="0" border="0" id="regmem"> <tr><th width="50%">Removed</th><th width="50%">Added</th></tr> <?php uksort($data, 'by_name_ref'); foreach ($data as $person_id => $v) { $out = ''; foreach ($v as $cat_type => $vv) { $out .= cat_heading($cat_type, $old_iso, $new_iso); $old = array_key_exists('old', $data[$person_id][$cat_type]) ? $data[$person_id][$cat_type]['old'] : ''; $new = array_key_exists('new', $data[$person_id][$cat_type]) ? $data[$person_id][$cat_type]['new'] : ''; $out .= clean_diff($old, $new); } if ($out) { print span_row('<h2>' . $names[$person_id] . ' - <a href="?p=' . $person_id . '">Register history</a> | <a href="http://www.theyworkforyou.com/mp/?pid=' . $person_id . '">MP\'s page</a></h2>', true) . $out; } } print '</table>'; }