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);
}
Example #2
0
<?php

/* 
 *
 */
require_once '../conf/general';
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;
}
Example #3
0
function view()
{
    $art_id = null;
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        $f = new ArticleModelForm($_POST, array(), array());
        if ($f->is_valid()) {
            $art = $f->save();
            db_commit();
            // redirect to prevent multiple POSTs
            $url = sprintf("http://%s/adm/article/%s", $_SERVER['HTTP_HOST'], article_id_to_id36($art['id']));
            header("HTTP/1.1 303 See Other");
            header("Location: {$url}");
            return;
        }
    } else {
        // handle either base-10 or base-36 article ids
        $art_id = get_http_var('id36');
        if ($art_id) {
            $art_id = article_id36_to_id($art_id);
        } else {
            $art_id = get_http_var('id');
        }
        if ($art_id) {
            $f = ArticleModelForm::from_db($art_id);
        } else {
            $initial = array();
            if (isset($_GET['url'])) {
                $initial['permalink'] = $_GET['url'];
            }
            if (isset($_GET['journo'])) {
                $initial['authors'] = $_GET['journo'];
            }
            $f = new ArticleModelForm(null, null, array('initial' => $initial));
            $art_id = null;
        }
    }
    $v = array('form' => $f, 'art_id' => $art_id);
    template($v);
}