function html_page_header($has_search = false, $query = '', $category = 'all') { global $config; $html = ''; $html .= '<div style="border-bottom:1px dotted rgb(128,128,128);padding-bottom:10px;">'; $html .= '<a href="' . $config['web_root'] . '"><span style="font-size:24px;">' . $config['site_name'] . '</span></a>'; if ($has_search) { echo html_search_box($query, $category); } $html .= '</div>'; return $html; }
function display_outlet($outlet) { global $couch; global $config; // clean $outlet = stripcslashes($outlet); echo html_html_open(); echo html_head_open(); echo html_title($outlet . ' - ' . $config['site_name']); echo html_include_css('css/main.css'); echo html_include_script('js/jquery-1.4.4.min.js'); echo html_head_close(); echo html_body_open(); echo '<div style="padding:10px;">'; //---------------------------------------------------------------------------------------------- // Home echo '<span><a href="' . $config['web_root'] . '">' . $config['site_name'] . '</a></span>'; echo html_search_box(); //---------------------------------------------------------------------------------------------- // Outlet echo '<h1>' . $outlet . '</h1>'; //http://localhost:5984/afd/_design/publication/_view/outlet_year_volume?startkey=[%22Annals%20And%20Magazine%20of%20Natural%20History%22]&endkey=[%22Annals%20And%20Magazine%20of%20Natural%20History\ufff0%22] $startkey = array($outlet); $endkey = array($outlet . '\\ufff0'); $resp = $couch->send("GET", "/" . $config['couchdb'] . "/_design/publication/_view/outlet_year_volume?startkey=" . urlencode(json_encode($startkey)) . "&endkey=" . urlencode(json_encode($endkey))); $articles = json_decode($resp); //print_r($articles); $num_articles = count($articles->rows); if (count($articles) == 0) { } else { echo '<h2>Articles in this publication (' . $num_articles . ')</h2>'; if ($num_articles < 20) { // list view echo '<ul>'; foreach ($articles->rows as $row) { $resp = $couch->send("GET", "/" . $config['couchdb'] . "/" . $row->value); $publication = json_decode($resp); if (isset($publication->error)) { // We don't have this reference } else { echo '<li style="list-style-type:none;">' . display_one_publication($publication) . '</li>'; } } echo '</ul>'; } else { // treemap view (should do this with a CouchDB index...) $years = array(); foreach ($articles->rows as $row) { $resp = $couch->send("GET", "/" . $config['couchdb'] . "/" . $row->value); $publication = json_decode($resp); if (isset($publication->error)) { // We don't have this reference } else { $year = 'YYYY'; if (isset($publication->year)) { $year = $publication->year; } if (!isset($years[$publication->year])) { $years[$publication->year] = array(); } $years[$publication->year][] = $row->value; } } // Get sizes of categories $size = array(); foreach ($years as $p) { $sizes[] = count($p); } // Get size of rectangle we want to draw this in $r = new Rectangle(0, 0, 400, 500); // Construct quantum treemap $qt = new QuantumTreemap($sizes, 1.0, $r); $qt->quantumLayout(); $json = $qt->export2json(); $obj = json_decode($json); // Add category labels and list of object ids to each cell in treemap $i = 0; foreach ($years as $k => $v) { $obj->rects[$i]->label = $k; $obj->rects[$i]->ids = array(); foreach ($v as $id) { $obj->rects[$i]->ids[] = $id; } $i++; } // Treemap echo "\n"; echo '<div style="position:relative">'; draw($obj); echo '</div>' . "\n"; } } echo '<div>'; echo html_body_close(false); echo html_html_close(); }