Skip to content

Commit

Permalink
Continue work on menu-generation code
Browse files Browse the repository at this point in the history
This generates a submenu per letter of the alphabet. Obviously, this ain't good enough, but I'm sick and my brain is busted. Toward #296.
  • Loading branch information
waldoj committed Sep 2, 2019
1 parent feac15f commit 70fa5c4
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions deploy/generate-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
* The resulting list is sent to stdout.
**/

require '../htdocs/includes/settings.inc.php';
require '../htdocs/includes/class.Database.php';

$database = new Database;
$db = $database->connect_mysqli();

/*
* Get a list of all legislators.
*/
$sql = 'SELECT name_formatted, shortname, chamber
$sql = 'SELECT name, name_formatted, shortname, chamber
FROM representatives
WHERE date_ended IS NOT NULL OR date_ended >= now()
ORDER BY chamber ASC, name ASC';
Expand All @@ -28,30 +31,52 @@
{

$legislator = array_map('stripslashes', $legislator);
$legislators[$legislator{'chamber'}][] = '<li><a href="/legislator/' . $legislator['shortname']
. ' /">' . $legislator . '</a></li>';
$legislators[$legislator{'chamber'}][substr($legislator{'name'}, 0, 1)][] = '<li><a href="/legislator/' . $legislator['shortname']
. ' /">' . $legislator['name_formatted'] . '</a></li>';

}

/*
*
* Establish our alphabetical groupings
*/
$house_categories = explode(',', 'a,i,d,m,s');
$senate_categories = explode(',', 'a,n');

/*
* Output menu data
*/
echo '
<ul>
<li>House »
<ul class="alphabetic">
<li>A–Z »
<ul class="legislators">
' . implode("\t", $legislators['house']) . '
<ul class="legislators">';

foreach ($legislators['house'] as $letter => $by_letter)
{
echo '<li>
' . $letter . ' »
<ul class="legislators">';
foreach ($by_letter as $legislator)
{
echo $legislator;
}
echo '</ul></li>';
}

echo '
</ul>
</li>
</ul>
</li>
<li>Senate »
<ul class="alphabetic">
<li>A–Z »
<ul class="legislators">
' . implode("\t", $legislators['senate']) . '
<ul class="legislators">';

echo implode("\t", $legislators['senate']);

echo '
</ul>
</li>
</ul>
Expand Down

0 comments on commit 70fa5c4

Please sign in to comment.