コード例 #1
0
function getBibliographyItem($name)
{
    assert(bibliographyItemExists($name));
    global $database;
    $sql = $database->prepare('SELECT bibliography_items.type, bibliography_values.key, bibliography_values.value, bibliography_items.name FROM bibliography_items, bibliography_values WHERE bibliography_items.name = :name AND bibliography_items.name = bibliography_values.name');
    $sql->bindParam(':name', $name);
    if ($sql->execute()) {
        $rows = $sql->fetchAll();
        // this output is a mess, sanitize it
        $result = array();
        foreach ($rows as $row) {
            $result['type'] = $row['type'];
            $result[$row['key']] = $row['value'];
            $result["name"] = $row["name"];
        }
        return $result;
    }
    return null;
}
コード例 #2
0
     $page = $_GET["page"];
 }
 // all the possible page building scenarios
 switch ($page) {
     case "about":
         $page = new AboutPage($database);
         break;
     case "acknowledgements":
         $page = new AcknowledgementsPage($database);
         break;
     case "api":
         $page = new APIPage($database);
         break;
     case "bibliography":
         if (!empty($_GET["key"])) {
             if (bibliographyItemExists($_GET["key"])) {
                 $page = new BibliographyItemPage($database, $_GET["key"]);
             } else {
                 $page = new NotFoundPage("<p>The bibliography item with the key <var>" . htmlentities($_GET["key"]) . "</var> does not exist.");
             }
         } else {
             $page = new BibliographyPage($database);
         }
         break;
     case "browse":
         $page = new BrowsePage($database);
         break;
     case "chapter":
         if (!is_numeric($_GET["chapter"]) or strstr($_GET["chapter"], ".") or intval($_GET["chapter"]) <= 0) {
             $page = new NotFoundPage("<p>The keys for a chapter should be (strictly) positive integers, but <var>" . htmlentities($_GET["chapter"]) . "</var> was provided.");
             break;