Revision history for CategoryTree


Revision [23469]

Last edited on 2016-05-20 07:38:48 by BrianKoontz [Replaces old-style internal links with new pipe-split links.]
Additions:
The results are presented [[http://www.net4lawyer.com/openlaw | here]].
Deletions:
The results are presented [[http://www.net4lawyer.com/openlaw here]].


Revision [21314]

Edited on 2011-01-17 15:48:08 by BrianKoontz [added line numbers]
Additions:
%%(php;1)
%%(php;1)


Revision [20824]

Edited on 2009-09-04 10:28:09 by FaKn [works as a real plugin and with template support for wikka 1.2]
Additions:
At the time only a dirty hack to show categories as a tree, initiated by LeOn, converted into a plugin by FaKn
The results are presented [[http://www.net4lawyer.com/openlaw here]].
====Implementation for Wikka 1.2====
Save the following as plugins/actions/categorytree.php
<?php
/**
* Displays a tree of all categories.
* For more info, see http://wikkawiki.org/CategoryTree
**/
if (!function_exists('f_action_categorytree_get_tree')) {
function f_action_categorytree_get_tree ($wakka) {
$imgpath = $wakka->GetThemePath()."/images/";
f_action_categorytree_get_level($wakka, 1, "CategoryCategory");
f_action_categorytree_get_level($wakka, 1, "KategorieKategorie");
function f_action_categorytree_is_parent ($name) {
function f_action_categorytree_get_level($wakka, $level, $parent = "CategoryCategory") {
$imgpath = $wakka->GetThemePath()."/images/";
if ($wakka->CheckMySQLVersion(4,0,1)) $results = $wakka->FullCategoryTextSearch($page);
else $results = $wakka->FullTextSearch($page);

if (f_action_categorytree_is_parent($val)) { // if element has children
// last empty element
if (($val == $active[$level]) and (f_action_categorytree_is_parent($val))) {
f_action_categorytree_get_level($wakka, $level+1, $active[$level]);
}
print f_action_categorytree_get_tree($this);
?>%%
Create a new custom theme (if you have not done this yet) by copying e.g. the 'light' theme from the 'templates' folder into 'plugins/templates'.
Append the following at the end of header.php
<div id="tree"><?php echo $this->Action('categoriestree') ?></div>%%
Now you only need some images (for example you can download all needed files here: http://www.polskieustawy.com/pics/tree/) and manipulations on wikka.css to see the right tree generated from your categories.
A simple addition to your copy of light.css is:
%%(css)
#tree {
border-right: 1px solid #DDD;
width: 200px;
padding: 10px 10px 10px 10px;
float: left;
}%%
Finally, switch to the new theme (either via your User settings or in the config, see http://docs.wikkawiki.org/WikkaThemes for more info).
====Implementation for Wikka 1.1.6.3====
This is the old code that works without plugins and templates:
Deletions:
At the time only a dirty hack to show categories as a tree, initiated by LeOn
The results are presented [[http://www.net4lawyer.com/openlaw here]]. At the time I call it "dirty hack", because it doesn't match the idea of WikkaWiki to use plugins / actions for Wikka expansions. Maybe somebody could help to make this hack better (and become to be a nice action).
**Implementation**:
As a start I put here only the code (all comments and instructions based on Wikka 1.1.6.3.):


Revision [19451]

Edited on 2008-01-28 00:16:02 by LeOn [Modified links pointing to docs server]

No Differences

Revision [17846]

Edited on 2007-12-17 07:41:24 by LeOn [Modified links pointing to docs server]
Additions:
**To do**:
1) Function to follow the navigation with the tree
If i open a page, that has an place in the tree, i would like to find it and show the tree open at the right place...
2) More precise documentation.
**Implementation**:
As a start I put here only the code (all comments and instructions based on Wikka 1.1.6.3.):
Deletions:
I will describe everything more precisely. As a start I put here only the code (all comments and instructions based on Wikka 1.1.6.3.):


Revision [17845]

Edited on 2007-12-17 07:37:49 by LeOn [Modified links pointing to docs server]
Additions:
The results are presented [[http://www.net4lawyer.com/openlaw here]]. At the time I call it "dirty hack", because it doesn't match the idea of WikkaWiki to use plugins / actions for Wikka expansions. Maybe somebody could help to make this hack better (and become to be a nice action).
Deletions:
The results are presented here. At the time I call it "dirty hack", because it doesn't match the idea of WikkaWiki to use plugins / actions for Wikka expansions. Maybe somebody could help to make this hack better (and become to be a nice action).


Revision [17562]

Edited on 2007-09-30 16:39:00 by LeOn [Modified links pointing to docs server]
Additions:
Now you need only some images (for example you can download all needed files here: http://www.polskieustawy.com/pics/tree/) and manipulations on wikka.css to see the right tree generated from your categories.
Deletions:
Now you need only some images (example here: http://www.polskieustawy.com/pics/tree/) and manipulations on wikka.css to see the right tree generated from your categories.


Revision [17561]

Edited on 2007-09-30 16:38:15 by LeOn [Modified links pointing to docs server]
Deletions:
<?php
?>


Revision [17560]

Edited on 2007-09-30 16:37:00 by LeOn [Modified links pointing to docs server]

No Differences

Revision [17559]

Edited on 2007-09-30 16:34:14 by LeOn [Modified links pointing to docs server]
Additions:
%%(php)


Revision [17558]

Edited on 2007-09-30 16:32:16 by LeOn [images link]
Additions:
Now you need only some images (example here: http://www.polskieustawy.com/pics/tree/) and manipulations on wikka.css to see the right tree generated from your categories.
To be continued!


Revision [17557]

Edited on 2007-09-30 16:28:31 by LeOn [adding functions]
Additions:
replace the line 1336 in Wakka.Class.php
with this code:
$lBody = "
<table border='0' width='100%'>
<tr valign='top'>
<td width='200px'>".$this->getTree()."</td>
<td width='*'>".$this->Method($this->method).$this->Footer()."</td>
</tr>
</table>";
print($this->Header().$lBody);
Then add following functions to the Wakka-class (in the same file Wakka.Class.php):
function getTree () {
$imgpath = "images/";
$txt = "<table cellspacing='0' cellpadding='0' border='0' width='100%'>";
$txt .= "<tr valign=top><td colspan='3' style='font-size: 12px' nowrap>";
$txt .= "<img src='".$imgpath."ksiazka_otw.gif' hspace=0 vspace=0 border=0 align=left>";
$txt .= " <b>Proszę wybrać kategorię:</b></td></tr>";
$txt .= "<tr valign=top><td height='4'></td></tr>";
if (!(isset($_SESSION["tree"]))) {
$_SESSION["active"] = array();
$this->getLevel(1, "CategoryCategory");
} else {
if (isset($_GET["active1"])) {
// call this recursive function for grab the tree
$_SESSION["tree"] = "";
$_SESSION["active"] = array();
$this->getLevel(1, "CategoryCategory");
} else {
// get the tree from session variable
// nothing necessary - the Text is saved in the session variable
}
}
$txt .= $_SESSION["tree"]."</table>";
return $txt;
}
function isParent ($name) {
if (preg_match("/^Category(.*)/i", $name)) return true;
else return false;
}
function getLevel($level, $parent = "CategoryCategory") {
// little function for checking, if a category member is a category
// or not (then it is an simple page)
$txt = $_SESSION["tree"]; // the text is saved in the session variable "tree"
$active = $_SESSION["active"];
$last = $_SESSION["last"];
$imgpath = "images/";
$page = $parent;
if ($this->CheckMySQLVersion(4,0,1)) $results = $this->FullCategoryTextSearch($page);
else $results = $this->FullTextSearch($page);
if ($results) {
//$txt .= "<table cellspacing='0' cellpadding='0' border='0' width='100%'>";
$count = 0;
$pagecount = 0;
$list = array();
$active[$level] = $_GET["active".$level];
foreach ($results as $i => $cpage) {
if($cpage['tag'] != $page) {
array_push($list,$cpage['tag']);
}
}
sort($list);
while (list($key, $val) = each($list)) {
//echo $key."; ".$val;
$count++;
$addin = "";
// control about the "addin" = pictures before the element
// in the tree - on levels under the first one
for ($x = 1; $x < $level; $x = $x+1) {
if ($last[$x] == 1) {//count($list)) {
$addin .= "<img src='".$imgpath."pusty_for_last.gif' hspace='0' vspace='0' border='0' align='left'>";
} else {
$addin .= "<img src='".$imgpath."menu_bar.gif' hspace='0' vspace='0' border='0' align='left'>";
}
}
$title = $val;
$nazwa = $val;
// preparing links for the tree elements
$myhref = "wakka=".$val;
for ($y = 1; $y <= $level; $y = $y+1) {
//echo $active[$y].";";
if ($y == $level) {
$myhref .= "&active".$y."=".$val;
} else {
$myhref .= "&active".$y."=".$active[$y];
}
}

if ($this->isParent($val)) { // if element has children
if ($count == count($list)) { // if last element on this level
if ($active[$level] == $val) {
$pic1 = "menu_corner_minus";
$pic2 = "ksiazka_otw";
} else {
$pic1 = "menu_corner_plus";
$pic2 = "ksiazka_zamk";
}
$last[$level] = 1;
} else {
if ($active[$level] == $val) {
$pic1 = "menu_tee_minus";
$pic2 = "ksiazka_otw";
} else {
$pic1 = "menu_tee_plus";
$pic2 = "ksiazka_zamk";
}
$last[$level] = 0;
}
} else {
// this elements doesn't have children (= categories without subcategories)
if (count($list) == $key+1) {
// ostatni pusty
$pic1 = "menu_corner";
$pic2 = "stronica";
} else {
// not last, regular tree element
$pic1 = "menu_tee";
$pic2 = "stronica";
}
}
$myA = "<a style='font-size: 12px; font-family: Arial;' href='wikka.php?".$myhref."' title='".$title."'>";
$txt .= "<tr valign='top'><td class='tree' nowrap>".$addin;
$txt .= $myA."<img src='".$imgpath.$pic1.".gif' hspace='0' vspace='0' border='0' align='left'></a>";
$txt .= $myA."<img src='".$imgpath.$pic2.".gif' hspace='0' vspace='0' border='0' align='left'></a> ";
if ($val == $_GET["wakka"]) {
$txt .= " <b>".$myA.$nazwa."</a></b>";
} else {
$txt .= " ".$myA.$nazwa."</a>";
}
$txt .= "</td></tr>";
// read next level, if necessary - but before that put some
// variables into session variables
$_SESSION["tree"] = $txt;
$_SESSION["last"] = $last;
$_SESSION["active"] = $active;
if (($val == $active[$level]) and ($this->isParent($val))) {
$this->getLevel($level+1, $active[$level]);
}
$active = $_SESSION["active"];
$txt = $_SESSION["tree"];
$last = $_SESSION["last"];
$pagecount++;
}
} else $txt .= 'Sorry, no items found for ' . $page .'.';
$_SESSION["last"] = $last;
$_SESSION["active"] = $active;
$_SESSION["tree"] = $txt;
}
Deletions:
replace the line 1336 in Wikka.Class.php


Revision [17556]

Edited on 2007-09-30 16:25:31 by LeOn [adding functions]
Additions:
<?php
Deletions:
<?


Revision [17555]

The oldest known version of this page was created on 2007-09-30 16:25:18 by LeOn [adding functions]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki