Skip to content

Commit

Permalink
Updated groupings of departments [#11]
Browse files Browse the repository at this point in the history
  • Loading branch information
Glen Barnes committed Jul 23, 2009
1 parent 2549274 commit 388dec3
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 53 deletions.
118 changes: 65 additions & 53 deletions themes/open-data-theme/category-25.php
Expand Up @@ -4,64 +4,76 @@
?>

<?php
$cats = array( 85 => "Office of Parliament",
87 => "Public Service Department",
90 => "State Sector",
75 => "Autonomous Crown Entity",
84 => "Non Public Service Department",
86 => "Other PFA 4th Schedule organisation",
76 => "City Council",
80 => "District Council",
88 => "Regional Council",
91 => "Territorial Authority",
81 => "District Health Board",
82 => "Education",
77 => "Conservation Sector Organisation",
78 => "Crown Agent",
79 => "Crown Research Institute",
83 => "Independent Crown entity",
89 => "State Owned Enterprise/Commercial Organisations",
92 => "Trust",
93 => "Wananga")
// $cats = array(
// 85 => "Office of Parliament",
// // 87 => "Public Service Department",
// // 90 => "State Sector",
// // 75 => "Autonomous Crown Entity",
// 84 => "Non Public Service Department",
// 86 => "Other PFA 4th Schedule organisation",
// 76 => "City Council",
// 80 => "District Council",
// 88 => "Regional Council",
// 91 => "Territorial Authority",
// 81 => "District Health Board",
// 82 => "Education",
// 77 => "Conservation Sector Organisation",
// 78 => "Crown Agent",
// 79 => "Crown Research Institute",
// 83 => "Independent Crown entity",
// 89 => "State Owned Enterprise/Commercial Organisations",
// 92 => "Trust",
// 93 => "Wananga")

// Central Government
// >Public Service Department
// >Crown Agents, Autonomous Crown Entities, Crown Entitity Companies, Trusts (suggest merge these categories into one alpha list)
// >DHBs
// >Crown Research Institutes
// >Reserve Bank of New Zealand
// >Non Public Service Departments
// >Office of Parliament
// >Education Institutions and Wananga (suggest merge these categories)
// >State-Owned Enterprises
// *Local Government*
// >City and District Councils
// > Regional Councils and Territorial Authorities
?>

<div id="wide_content">
<h1 class="cat_header">List of Departments, Agencies, Crown Research Institutes, Councils and Other Government Organsations</h1>
<p>Click through to see what datasets we have listed for each entity.</p>
<?php foreach ($cats as $cat_id => $title) : ?>
<?php
$sql = "select p.ID, p.post_title, sd.department, tr.term_taxonomy_id, ds_count.num_sets" .
" from (" . $wpdb->prefix . "posts as p, " .
$wpdb->prefix . "supple_dataset as sd, " .
$wpdb->prefix . "term_relationships as tr)" .
" left outer join " .
" (select sd.department, count(sd.department) as num_sets" .
" from " . $wpdb->prefix . "posts as p, " .
" " . $wpdb->prefix . "supple_dataset as sd," .
" " . $wpdb->prefix . "term_relationships as tr" .
" where p.ID = sd.post_id" .
" and p.ID = tr.object_id" .
" and tr.term_taxonomy_id = 3" .
" group by sd.department) as ds_count " .
" on sd.department = ds_count.department " .
" where p.ID = sd.post_id" .
" and p.ID = tr.object_id" .
" and tr.term_taxonomy_id = " . $cat_id .
" order by p.post_title ASC;";

$departments = $wpdb->get_results($sql, ARRAY_A); ?>
<?php if($departments) : ?>
<h2 class="department"><?php echo $title ?></h2>
<ul>
<?php foreach($departments as $department) : ?>
<li>
<a href="<?php echo get_permalink($department[ID]) ?>"><?php echo $department[post_title]; ?></a>
<?php if ($department[num_sets]) { echo '(' . $department[num_sets] . ' datasets)'; }; ?>
</li>
<?php endforeach;?>
</ul>
<? endif ?>
<?php endforeach; ?>
<h2 class="department">Central Government</h2>
<h3 class="department">Public Service Department</h3>
<?php output_department(87, $wpdb); ?>
<h3 class="department">Crown Agents, Autonomous Crown Entities, Crown Entitity Companies, Trusts</h3>
<?php output_department(78, $wpdb); ?>
<?php output_department(75, $wpdb); ?>
<?php output_department(83, $wpdb); ?>
<?php output_department(92, $wpdb); ?>
<h3 class="department">DHBs </h3>
<?php output_department(81, $wpdb); ?>
<h3 class="department">Crown Research Institutes </h3>
<?php output_department(79, $wpdb); ?>
<h3 class="department">Reserve Bank of New Zealand </h3>
<?php output_department(90, $wpdb); ?>
<h3 class="department">Non Public Service Departments</h3>
<?php output_department(84, $wpdb); ?>
<h3 class="department">Office of Parliament </h3>
<?php output_department(85, $wpdb); ?>
<h3 class="department">Education Institutions and Wananga </h3>
<?php output_department(82, $wpdb); ?>
<?php output_department(93, $wpdb); ?>
<h3 class="department">State-Owned Enterprises</h3>
<?php output_department(89, $wpdb); ?>
<h2 class="department">Local Government</h2>
<h3 class="department">City and District Councils</h3>
<?php output_department(76, $wpdb); ?>
<?php output_department(80, $wpdb); ?>
<h3 class="department">Regional Councils and Territorial Authorities</h3>
<?php output_department(88, $wpdb); ?>
<?php output_department(91, $wpdb); ?>

</div>

<?php get_footer(); ?>
33 changes: 33 additions & 0 deletions themes/open-data-theme/functions.php
Expand Up @@ -79,6 +79,39 @@ function output_label($value, $lookup) {
return $str;
}

function output_department($cat_id, $wpdb) {
$sql = "select p.ID, p.post_title, sd.department, tr.term_taxonomy_id, ds_count.num_sets" .
" from (" . $wpdb->prefix . "posts as p, " .
$wpdb->prefix . "supple_dataset as sd, " .
$wpdb->prefix . "term_relationships as tr)" .
" left outer join " .
" (select sd.department, count(sd.department) as num_sets" .
" from " . $wpdb->prefix . "posts as p, " .
" " . $wpdb->prefix . "supple_dataset as sd," .
" " . $wpdb->prefix . "term_relationships as tr" .
" where p.ID = sd.post_id" .
" and p.ID = tr.object_id" .
" and tr.term_taxonomy_id = 3" .
" group by sd.department) as ds_count " .
" on sd.department = ds_count.department " .
" where p.ID = sd.post_id" .
" and p.ID = tr.object_id" .
" and tr.term_taxonomy_id = " . $cat_id .
" order by p.post_title ASC;";

$departments = $wpdb->get_results($sql, ARRAY_A);
if($departments) :
echo "<ul>";
foreach($departments as $department) :
echo "<li>";
echo "<a href=\"" . get_permalink($department[ID]) ."\">" . $department[post_title] . "</a>";
if ($department[num_sets]) { echo '(' . $department[num_sets] . ' datasets)'; };
echo "</li>";
endforeach;
echo "</ul>";
endif;
}


$licenses
?>
5 changes: 5 additions & 0 deletions themes/open-data-theme/style.css
Expand Up @@ -471,4 +471,9 @@ h2.department {
font-size:20px;
font-weight:bold;
padding: 10px 0 10px 0;
}
h3.department {
font-size:17px;
font-weight:bold;
padding: 10px 0 10px 0;
}

0 comments on commit 388dec3

Please sign in to comment.