Revision history for MyTree


Revision [843]

Last edited on 2017-02-10 20:51:13 by WojciechLisiewicz
Additions:
see http://wdb.fh-sm.de/WikiProgrammingDoku

Deletions:
%%(php;1)
-------------------------

// 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;
$list = array();
$active = array(); // lista elementów aktywnych na wszystkich poziomach
$last = array(); // lista elementów ostatnich na poziomach = czujnik do wyglądu
$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) {
array_push($list,$cpage['tag']);
}
}
sort($list);
while (list($key, $val) = each($list)) {
$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]))) {
if ($count == 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>";
}

$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 ($count == count($list)) { // jeśli jest to ostatni w liście na danym poziomie
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;
}

------------------------
%%


Additions:
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'>";
// 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;
$list = array();
$active = array(); // lista elementów aktywnych na wszystkich poziomach
$last = array(); // lista elementów ostatnich na poziomach = czujnik do wyglądu
$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) {
array_push($list,$cpage['tag']);
}
sort($list);
while (list($key, $val) = each($list)) {
$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]))) {
if ($count == 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>";
}

$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 ($count == count($list)) { // jeśli jest to ostatni w liście na danym poziomie
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;
}

Deletions:
for ($x = 1; $x <= $rssize; $x = $x+1) {
$wybrany = 5; // aktywny element, ten który aktualnie wybrano;
$cat = $wybrany; // w drzewie pu.com oparto o id elementu;
$myid = $key; // element aktualnie opracowywany w pętli
// w pu.com w oparciu o $rec["id"];

$title = $rec["nazwa"];
$nazwa = $rec["alt"];
if ($nazwa == "") $nazwa = $rec["nazwa"];
$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 ($rec["logic"] == 0) {
if ($x == $rssize) {
// ostatni pusty
$pic1 = "menu_corner";
$pic2 = "stronica";
} else {
// nieostatni pusty
$pic1 = "menu_tee";
$pic2 = "stronica";
} else {
if ($x == $rssize) {
if ($active[$level] == $myid) {
$pic1 = "menu_corner_minus";
$pic2 = "ksiazka_otw";
} else {
$pic1 = "menu_corner_plus";
$pic2 = "ksiazka_zamk";
$last[$level] = 1;
} else {
if ($active[$level] == $myid) {
$pic1 = "menu_tee_minus";
$pic2 = "ksiazka_otw";
} else {
$pic1 = "menu_tee_plus";
$pic2 = "ksiazka_zamk";
$last[$level] = 0;
$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='".$_SESSION['treepics'].$pic1.".gif' hspace=0 vspace=0 border=0 align=left></a>";
$txt .= $myA."<img src='".$_SESSION['treepics'].$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>";
// jesli konieczne, wlacz kolejny poziom
if ($active[$level] == $myid) getLevel($active[$level], $level+1, $conn, &$txt, $active, $cat, $last);
$rec = mysql_fetch_array($rs);
}


Revision [287]

The oldest known version of this page was created on 2007-09-16 21:17:09 by WojciechLisiewicz
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki