Beispiel #1
0
function db_retrieve_authored_references($author_id, $start = 0, $limit = 10)
{
    global $db;
    global $ADODB_FETCH_MODE;
    $refs = array();
    // Authored by just this author name
    /*	$sql = 'SELECT * FROM rdmp_reference
    INNER JOIN rdmp_author_reference_joiner USING (reference_id)
    	WHERE (author_id = ' . $author_id . ')
    ORDER BY year'; */
    // Authored by cluster of names
    $author_cluster_id = db_get_author_cluster_id($author_id);
    $sql = 'SELECT * FROM rdmp_reference
INNER JOIN rdmp_author_reference_joiner USING (reference_id)
INNER JOIN rdmp_author USING (author_id)
WHERE (author_cluster_id = ' . $author_cluster_id . ')
ORDER BY year';
    $result = $db->Execute($sql);
    if ($result == false) {
        die("failed [" . __FILE__ . ":" . __LINE__ . "]: " . $sql);
    }
    while (!$result->EOF) {
        $refs[] = $result->fields['reference_id'];
        $result->MoveNext();
    }
    return $refs;
}
Beispiel #2
0
function sparkline_author_articles($author_id, $width = 300, $height = 50)
{
    global $db;
    $author_cluster_id = db_get_author_cluster_id($author_id);
    $sql = 'SELECT year, count(reference_id) AS c FROM rdmp_reference
INNER JOIN rdmp_author_reference_joiner USING (reference_id)
INNER JOIN rdmp_author USING (author_id)
WHERE (author_cluster_id = ' . $author_cluster_id . ')
GROUP BY YEAR
ORDER BY year';
    $start_year = 3000;
    $end_year = 0;
    $max_value = 0;
    $count = array();
    $result = $db->Execute($sql);
    if ($result == false) {
        die("failed [" . __FILE__ . ":" . __LINE__ . "]: " . $sql);
    }
    while (!$result->EOF) {
        $start_year = min($start_year, $result->fields['year']);
        $end_year = max($end_year, $result->fields['year']);
        $max_value = max($max_value, $result->fields['c']);
        $count[$result->fields['year']] = $result->fields['c'];
        $result->MoveNext();
    }
    $start_year = floor($start_year / 10) * 10;
    $end_year = floor(($end_year + 9) / 10) * 10;
    for ($i = $start_year; $i <= $end_year; $i++) {
        if (!isset($count[$i])) {
            $count[$i] = 0;
        }
    }
    ksort($count);
    // Axes
    $decades = array();
    for ($i = $start_year; $i <= $end_year; $i += 10) {
        $decades[] = $i;
    }
    $values = array();
    foreach ($count as $k => $v) {
        $values[] = round($v * 100.0 / $max_value);
    }
    $url = 'http://chart.apis.google.com/chart?chs=' . $width . 'x' . $height . '&cht=ls&chco=0077CC&chm=B,e6f2fa,0,0.0,0.0&chd=t:';
    $url .= join(",", $values);
    $url .= '&chxt=x,y&chxl=0:|' . join("|", $decades) . '|1:||' . $max_value;
    return $url;
}