Пример #1
0
function fetch_art($art_id)
{
    $art = article_collect($art_id);
    // journos (article_collect() only grabs active ones)
    $sql = <<<EOT
SELECT j.prettyname, j.ref, j.status, j.oneliner
    FROM ( journo j INNER JOIN journo_attr attr ON j.id=attr.journo_id )
    WHERE attr.article_id=?
EOT;
    $art['journos'] = db_getAll($sql, $art_id);
    return $art;
}
Пример #2
0
function api_getArticles_invoke($params)
{
    $article_ids = array();
    if ($params['id36']) {
        $id36s = preg_split("/[\\s,]+/", $params['id36']);
        foreach ($id36s as $id36) {
            $article_ids[] = article_id36_to_id($id36);
        }
    }
    if ($params['url']) {
        // look up article by its original url
        $url = $params['url'];
        $art_id = article_find($url);
        if (is_null($art_id)) {
            api_error("couldn't find article with url: '" . $url . "'");
            return;
        }
        $article_ids[] = $art_id;
    }
    if (!$article_ids) {
        api_error("No articles specified - use 'id36' and/or 'url'");
        return;
    }
    #$brief = $params['brief'] ? TRUE : FALSE;
    $fields = array('title', 'id36', 'srcorgname', 'iso_pubdate', 'permalink', 'journos', 'description');
    $results = array();
    foreach ($article_ids as $id) {
        $raw = article_collect($id);
        $art = array_cherrypick($raw, $fields);
        $results[] = $art;
    }
    $output = array('status' => 0, 'results' => $results);
    api_output($output);
}
Пример #3
0
require_once '../phplib/page.php';
require_once '../phplib/misc.php';
require_once '../phplib/article.php';
require_once '../phplib/article_rdf.php';
require_once '../../phplib/db.php';
require_once '../../phplib/utility.php';
// handle either base-10 or base-36 article ids
$article_id = get_http_var('id36');
if ($article_id) {
    $article_id = article_id36_to_id($article_id);
} else {
    $article_id = get_http_var('id');
}
$sim_orderby = strtolower(get_http_var('sim_orderby', 'score'));
$sim_showall = strtolower(get_http_var('sim_showall', 'no'));
$art = article_collect($article_id, $sim_orderby, $sim_showall);
/* TODO: show a more useful 404/410 page for missing/hidden articles! */
if (is_null($art)) {
    header('HTTP/1.1 404 Not Found');
    return;
}
if ($art['status'] == 'h') {
    header('HTTP/1.1 410 Gone');
    return;
}
if ($art['status'] != 'a') {
    header('HTTP/1.1 404 Not Found');
    return;
}
$fmt = get_http_var('fmt');
if ($fmt == "rdfxml") {