Baum mit Kategorien in WikkaWiki
Funktionsweise und Skripte
Siehe libs/wikka.class.php gegen Ende:
- -------------------------
 - // tree from polskieustawy
 - function getTree () {
 - $imgpath = "images/";
 - $txt = "<table cellspacing='0' cellpadding='0' border='0' width='100%'>";
 - $txt .= "<tr valign=top><td 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'>";
 - $txt .= "</td></tr>";
 - // call this recursive function for grab the tree
 - $txt .= $this->getLevel("CategoryWiki");
 - $txt .= "</table>";
 - return $txt;
 - }
 - function getLevel($catname = "CategoryCategory") {
 - function isParent () {
 - // check, if one is parent of other
 - return true;
 - }
 - $imgpath = "images/";
 - //if ($cattag = $_GET['wakka']) {}
 - $txt = ""; //$str ="";
 - $page = $catname; //"CategoryWiki";
 - if ($page=="/") $page="CategoryCategory";
 - 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;
 - $level = 1; // dummy => później pobierać jako numer poszczególnych przerabianych poziomów
 - $active[$level] = 3; // dummy => później pobierać jako numer otwartego na poziomie $level
 - foreach ($results as $i => $cpage) {
 - if($cpage['tag'] != $page) {
 - }
 - }
 - $count++;
 - // kontrola nad "addin", czyli obrazkiem przeznaczonym do wyświetlenia przed samym elementem
 - // drzewka - związane z przesunięciem poziomów drzewka
 - //if (!(isset($last[$x]))) {
 - $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>";
 - }
 - $wybrany = 5; // aktywny element, ten który aktualnie wybrano;
 - $cat = $wybrany; // w drzewie pu.com oparto o id elementu; -> wartość rezerwowa
 - $myid = $key + 1; // element aktualnie opracowywany w pętli
 - // w pu.com w oparciu o $rec["id"];
 - $title = $val;
 - $nazwa = $val;
 - $myhref = "";
 - //for ($y = 1; $y <= $level; $y = $y+1) {
 - // if ($y == $level) {
 - // $myhref .= "&a".$y."=".$rec["id"];
 - // } else {
 - // $myhref .= "&a".$y."=".$active[$y];
 - // }
 - //}
 - $myhref .= "&cat=".$myid;
 - if (isParent()) { // jeśli element ma dzieci
 - if ($active[$level] == $key+1) {
 - $pic1 = "menu_corner_minus";
 - $pic2 = "ksiazka_otw";
 - } else {
 - $pic1 = "menu_corner_plus";
 - $pic2 = "ksiazka_zamk";
 - }
 - $last[$level] = 1;
 - } else {
 - if ($active[$level] == $key+1) {
 - $pic1 = "menu_tee_minus";
 - $pic2 = "ksiazka_otw";
 - } else {
 - $pic1 = "menu_tee_plus";
 - $pic2 = "ksiazka_zamk";
 - }
 - $last[$level] = 0;
 - }
 - } else {
 - // tutaj elementy nie posiadają już dzieci!!!
 - if ($active[$level] == $key) {
 - // ostatni pusty
 - $pic1 = "menu_corner";
 - $pic2 = "stronica";
 - } else {
 - // nieostatni pusty
 - $pic1 = "menu_tee";
 - $pic2 = "stronica";
 - }
 - }
 - $myA = "<a href='?".$myhref."' title='".$title."' style='text-decoration:none; font-family:arial;'>";
 - $txt .= "<tr valign=top><td style='font-size: 12px' 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 ($myid == $cat) {
 - $txt .= " <b>".$myA.$nazwa."</b></a></b>";
 - } else {
 - $txt .= " ".$myA.$nazwa."</a>";
 - }
 - $txt .= "</td></tr>";
 - // jesli konieczne, wlacz kolejny poziom
 - //if ($active[$level] == $myid) getLevel($active[$level], $level+1, $conn, &$txt, $active, $cat, $last);
 - //$rec = mysql_fetch_array($rs);
 - $pagecount++;
 - }
 - //$txt .= '</table>';
 - } else $txt .= 'Sorry, no items found for ' . $page .'.';
 - return $txt;
 - }
 - ------------------------
 
Diese Seite wurde noch nicht kommentiert.