summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/controllers/welcome.php28
-rw-r--r--core/views/welcome.html.php11
2 files changed, 39 insertions, 0 deletions
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php
index f421ffc5..c8b76a0f 100644
--- a/core/controllers/welcome.php
+++ b/core/controllers/welcome.php
@@ -45,6 +45,34 @@ class Welcome_Controller extends Template_Controller {
url::redirect("welcome");
}
+ function mptt() {
+ $this->auto_render = false;
+ $items = ORM::factory("item")->orderby("id")->find_all();
+ $data = "digraph G {\n";
+ foreach ($items as $item) {
+ $data .= " $item->parent_id -> $item->id\n";
+ $data .= " $item->id [label=\"$item->id <$item->left, $item->right>\"]\n";
+ }
+ $data .= "}\n";
+
+ if ($this->input->get("type") == "text") {
+ print "<pre>$data";
+ } else {
+ $proc = proc_open("/usr/bin/dot -Tsvg",
+ array(array("pipe", "r"),
+ array("pipe", "w")),
+ $pipes,
+ VARPATH . "tmp");
+ fwrite($pipes[0], $data);
+ fclose($pipes[0]);
+
+ header("Content-Type: image/svg+xml");
+ print(stream_get_contents($pipes[1]));
+ fclose($pipes[1]);
+ proc_close($proc);
+ }
+ }
+
function add($count) {
srand(time());
$parents = ORM::factory("item")->where("type", "album")->find_all()->as_array();
diff --git a/core/views/welcome.html.php b/core/views/welcome.html.php
index 4bd0ef90..af4cb68b 100644
--- a/core/views/welcome.html.php
+++ b/core/views/welcome.html.php
@@ -132,6 +132,7 @@
<ul id="tabs">
<li><a href="javascript:show('#configuration')">Configuration</a></li>
<li><a href="javascript:show('#actions')">Actions</a></li>
+ <li><a href="javascript:show('#info')">Info</a></li>
<li><a href="javascript:show('#docs')">Docs</a></li>
</ul>
@@ -161,6 +162,16 @@
</ul>
</div>
+ <div id="info" class="activity">
+ <ul>
+ <li> <?= html::anchor("welcome/mptt&type=text", "MPTT tree (text)") ?> </li>
+ <li>
+ <?= html::anchor("welcome/mptt", "MPTT tree (graph)") ?>
+ <i>(requires /usr/bin/dot from the graphviz package)</i>
+ </li>
+ </ul>
+ </div>
+
<div id="docs" class="activity">
<ul>
<li>