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; }
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);
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> > "; $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 .= " > <a href='" . href("tag/" . $enclosingTag["tag"]) . "'>" . ucfirst($enclosingTag["type"]) . " " . $enclosingTag["book_id"] . "</a>"; } return $output; }