예제 #1
0
파일: articles.php 프로젝트: rair/yacs
 /**
  * get one article by id, nick name or by handle
  *
  * @param int the id of the article
  * @param boolean TRUE to always fetch a fresh instance, FALSE to enable cache
  * @return the resulting $item array, with at least keys: 'id', 'title', 'description', etc.
  */
 public static function get($id, $mutable = FALSE)
 {
     $output = Articles::get_attributes($id, '*', $mutable);
     return $output;
 }
예제 #2
0
파일: element.php 프로젝트: rair/yacs
}
// no not kill script validation
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'HEAD') {
    return;
}
// not found -- help web crawlers
if (!isset($item['id'])) {
    Safe::header('Status: 404 Not Found', TRUE, 404);
    die(i18n::s('No item has the provided id.'));
    // permission denied
} elseif (!$permitted) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    die(i18n::s('You are not allowed to perform this operation.'));
    // retrieve some attributes
} elseif ($action) {
    $response = Articles::get_attributes($item['id'], $action);
    // encode result in JSON
    $output = Safe::json_encode($response);
    // allow for data compression
    render_raw('application/json; charset=' . $context['charset']);
    // actual transmission except on a HEAD request
    if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
        echo $output;
    }
    // the post-processing hook, then exit
    finalize_page(TRUE);
    // update some attributes
} else {
    if (Articles::put_attributes($_REQUEST)) {
        die('OK');
    }