Exemplo n.º 1
0
 private function printResult($result, $includeProofs)
 {
     $output = "";
     switch ($result["type"]) {
         case "item":
             $parent = getEnclosingTag($result["position"]);
             $section = getEnclosingSection($result["position"]);
             // enumeration can live in sections, hence we should take care of this sidecase
             if ($parent["tag"] == $section["tag"]) {
                 $output .= "<li><p><a href='" . href("tag/" . $result["tag"]) . "'>" . ucfirst($result["type"]) . " " . $result["book_id"] . "</a> of the enumeration in <a href='" . href("tag/" . $section["tag"]) . "'>" . ucfirst($section["type"]) . " " . $section["book_id"] . "</a></p>";
             } else {
                 $output .= "<li><p><a href='" . href("tag/" . $result["tag"]) . "'>" . ucfirst($result["type"]) . " " . $result["book_id"] . "</a> of the enumeration in <a href='" . href("tag/" . $parent["tag"]) . "'>" . ucfirst($parent["type"]) . " " . $parent["book_id"] . "</a> in <a href='" . href("tag/" . $section["tag"]) . "'>" . "Section " . $section["book_id"] . ": " . parseAccents($section["name"]) . "</a></p>";
             }
             break;
         case "section":
             $output .= "<li><p><a href='" . href("tag/" . $result["tag"]) . "'>" . ucfirst($result["type"]) . " " . $result["book_id"] . ((!empty($result["name"]) and $result["type"] != "equation") ? ": " . parseAccents($result["name"]) . "</a>" : "</a>") . "</p>";
             break;
         default:
             $section = getEnclosingSection($result["position"]);
             $output .= "<li><p><a href='" . href("tag/" . $result["tag"]) . "'>" . ucfirst($result["type"]) . " " . $result["book_id"] . ((!empty($result["name"]) and $result["type"] != "equation") ? ": " . parseAccents($result["name"]) . "</a>" : "</a>") . " in <a href='" . href("tag/" . $section["tag"]) . "'>" . "Section " . $section["book_id"] . ": " . parseAccents($section["name"]) . "</a></p>";
             break;
     }
     if (!in_array($result["type"], array("section", "subsection"))) {
         if ($includeProofs) {
             $output .= "<pre class='preview' id='text-" . $result["tag"] . "'>" . parsePreview($result["text"]) . "</pre>";
         } else {
             $output .= "<pre class='preview' id='text-" . $result["tag"] . "'>" . parsePreview($result["text_without_proofs"]) . "</pre>";
         }
     }
     return $output;
 }
Exemplo n.º 2
0
function getCommentsSidebar($db)
{
    $comments = get_comments($db, 0, 6);
    $value = "";
    $maxAuthorLength = 15;
    $value .= "<h2><a href='" . href("recent-comments.xml") . "' class='rss'>Recent comments</a></h2>";
    $value .= "<ul>";
    foreach ($comments as $comment) {
        $date = new DateTime($comment["date"]);
        $value .= "<li>" . date_format($date, "j F Y, g:i a") . ":<br> ";
        if (strlen($comment["author"]) > $maxAuthorLength) {
            $value .= htmlentities(mb_substr($comment["author"], 0, $maxAuthorLength, "UTF-8")) . "...";
        } else {
            $value .= htmlentities($comment["author"]);
        }
        $tag = getTag($comment["tag"]);
        $section = getEnclosingSection($tag["position"]);
        $value .= " on <a title='in section " . $section["book_id"] . " " . parseAccents($section["name"]) . "' href='" . href("tag/" . $comment["tag"] . "#comment-" . $comment["id"]) . "'>tag " . $comment["tag"] . "</a>";
    }
    $value .= "</ul>";
    return $value;
}
Exemplo n.º 3
0
error_reporting(E_ALL);
// read configuration file
$config = parse_ini_file("../../config.ini");
// initialize the global database object
try {
    $database = new PDO("sqlite:" . "../../" . $config["database"]);
} catch (PDOException $e) {
    echo $e->getMessage();
}
if (!isValidTag($_GET["tag"])) {
    print "This tag is not valid.";
    exit;
}
if (!tagExists($_GET["tag"])) {
    print "This tag does not exist.";
    exit;
}
$tag = getTag($_GET["tag"]);
$chapter = getEnclosingChapter($tag["position"]);
$section = getEnclosingSection($tag["position"]);
$result = array();
$result["type"] = $tag["type"];
$result["label"] = $tag["label"];
$result["chapter_page"] = $tag["chapter_page"];
$result["book_page"] = $tag["book_page"];
$result["book_id"] = $tag["book_id"];
$result["value"] = $tag["value"];
$result["slogan"] = $tag["slogan"];
$result["chapter_name"] = $chapter["name"];
$result["section_name"] = $section["name"];
print json_encode($result);
Exemplo n.º 4
0
 public function getMain()
 {
     $output = "";
     $output .= "<h2>Tag <var>" . $this->tag["tag"] . "</var></h2>";
     $output .= "<p>Go to the <a href='" . href("tag/" . $this->tag["tag"]) . "'>corresponding tag page</a>.</p>";
     $output .= "<h3>Information on the label</h3>";
     $output .= "<p>This tag currently has the label <var>" . $this->tag["label"] . "</var>.";
     $output .= "<dl>";
     $output .= "<dt>Part of the Stacks project since</dt>";
     if ($this->tag["creation_date"] == "May 16 11:14:00 2009 -0400") {
         $output .= "<dd>" . $this->tag["creation_date"] . " (see <a href='" . href("tags#stacks-epoch") . "'>Stacks epoch</a>) in <a href='https://github.com/stacks/stacks-project/commit/" . $this->tag["creation_commit"] . "'>commit " . substr($this->tag["creation_commit"], 0, 7) . "</a>.</dd>";
     } else {
         $output .= "<dd>" . $this->tag["creation_date"] . " in <a href='https://github.com/stacks/stacks-project/commit/" . $this->tag["creation_commit"] . "'>commit " . substr($this->tag["creation_commit"], 0, 7) . "</a>.</dd>";
     }
     $output .= "<dt>Last modification to this label (not its contents)</dt>";
     $output .= "<dd>" . $this->tag["modification_date"] . " in <a href='https://github.com/stacks/stacks-project/commit/" . $this->tag["modification_commit"] . "'>commit " . substr($this->tag["modification_commit"], 0, 7) . "</a>.</dd>";
     $output .= "</dl>";
     $output .= "<h3>Numbers</h3>";
     $output .= "<p>The dependency graph has the following properties";
     $output .= "<table class='alternating' id='numbers'>";
     $referencingTags = getReferencingTags($this->tag["tag"]);
     $referredTags = getReferredTags($this->tag["tag"]);
     $output .= printStatisticsRow("number of nodes", $this->graphs["node_count"]);
     $output .= printStatisticsRow("number of edges", $this->graphs["edge_count"], "(ignoring multiplicity)");
     $output .= printStatisticsRow("", $this->graphs["total_edge_count"], "(with multiplicity)");
     $output .= printStatisticsRow("number of chapters used", $this->graphs["chapter_count"]);
     $output .= printStatisticsRow("number of sections used", $this->graphs["section_count"]);
     $output .= printStatisticsRow("number of tags directly used", count($referredTags));
     if (count($referencingTags) > 0) {
         $output .= printStatisticsRow("number of tags using this tag", $this->graphs["use_count"], "(directly, see <a href='#referencing'>tags referencing this result</a>)");
     } else {
         $output .= printStatisticsRow("number of tags using this tag", $this->graphs["use_count"], "(directly)");
     }
     $output .= printStatisticsRow("", $this->graphs["indirect_use_count"] - 1, "(both directly and indirectly)");
     $output .= "</table>";
     if (count($referencingTags) > 0) {
         $output .= "<h3 id='referencing'>Tags using this result</h3>";
         $output .= "<ul id='using'>";
         $referencingTags = getReferencingTags($this->tag["tag"]);
         foreach ($referencingTags as $referencingTag) {
             if ($referencingTag["name"] != "") {
                 $output .= "<li><a href='" . href("tag/" . $referencingTag["source"]) . "'>" . ucfirst($referencingTag["type"]) . " " . $referencingTag["book_id"] . ": " . parseAccents($referencingTag["name"]) . "</a>";
             } else {
                 $output .= "<li><a href='" . href("tag/" . $referencingTag["source"]) . "'>" . ucfirst($referencingTag["type"]) . " " . $referencingTag["book_id"] . "</a>";
             }
             $section = getEnclosingSection($referencingTag["position"]);
             $chapter = getEnclosingChapter($referencingTag["position"]);
             $output .= ", in " . parseAccents($section["name"]);
             $output .= " of Chapter " . $chapter["book_id"] . ": " . parseAccents($chapter["name"]);
             $output .= "<br>(go to <a href='" . href("tag/" . $referencingTag["source"] . "/statistics") . "'>statistics</a>)";
         }
         $output .= "</ul>";
     }
     return $output;
 }
Exemplo n.º 5
0
 private function printBreadcrumb()
 {
     $output = "";
     $chapter = getEnclosingChapter($this->tag["position"]);
     $section = getEnclosingSection($this->tag["position"]);
     $output .= "<p style='font-size: .9em'><a href='" . href("tag/" . $chapter["tag"]) . "'>Chapter " . $chapter["book_id"] . ": " . parseAccents($chapter["name"]) . "</a> &gt;&ensp;";
     $output .= "<a href='" . href("tag/" . $section["tag"]) . "'>Section " . $section["book_id"] . ": " . parseAccents($section["name"]) . "</a>";
     if ($this->tag["type"] == "item" or $this->tag["type"] == "equation") {
         $enclosingTag = getEnclosingTag($this->tag["position"]);
         $output .= " &gt;&ensp;<a href='" . href("tag/" . $enclosingTag["tag"]) . "'>" . ucfirst($enclosingTag["type"]) . "&nbsp;" . $enclosingTag["book_id"] . "</a>";
     }
     return $output;
 }