示例#1
0
 function print_tree($descId, $type = "", $depth = "")
 {
     switch ($type) {
         case txt:
             $delimitor = "*";
             break;
         case csv:
             $delimitor = ";";
             break;
         case adlib:
             $adlibString = adlib($descId, $type);
             return $adlibString;
             break;
     }
     // display id entry
     $comment = thesaurus::get_comment($descId);
     // remove \r\n
     $comment = str_replace("\n", '', $comment);
     $comment = str_replace("\r", '', $comment);
     $paramArray = explode(";", $comment);
     $idArray = explode("=", $paramArray[0]);
     $rootArray = explode("=", $paramArray[1]);
     $commentArray = explode("=", $paramArray[2]);
     $levelCnt = 7;
     // insert title
     if (!$depth) {
         $treeString .= $idArray[0] . $delimitor;
         for ($i = 0; $i < $levelCnt; $i++) {
             $treeString .= "Level {$i}" . $delimitor;
         }
         $treeString .= $delimitor . $rootArray[0] . $delimitor . $commentArray[0] . "\r\n";
     }
     // insert id at beginning
     $treeString .= $idArray[1] . $delimitor;
     // insert blank tree elements on beginn
     $i = 0;
     while ($i++ < $depth - 1) {
         $treeString .= $delimitor;
     }
     if ($type == "txt") {
         $treeString .= " ";
     }
     // whitespace in textfile
     // display entry
     $treeString .= thesaurus::get_name($descId);
     // insert blank tree elements at end
     while ($i++ < $levelCnt) {
         $treeString .= $delimitor;
     }
     if ($type == "txt") {
         $treeString .= " ";
     }
     // whitespace in textfile
     // insert root entry
     $treeString .= $delimitor . "{$rootArray['1']}";
     // insert comment entry
     $treeString .= $delimitor . "{$commentArray['1']}";
     // insert crlf
     $treeString .= "\r\n";
     $childArray = thesaurus::get_child($descId);
     // loop all childs recursive
     if (is_array($childArray)) {
         foreach ($childArray as $entry) {
             $treeString .= export::print_tree($entry, $type, $depth + 1);
         }
     }
     return $treeString;
 }
示例#2
0
</head>


<body>
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>

<?php 
foreach ($_GET as $key => $value) {
    ${$key} = $value;
}
foreach ($_POST as $key => $value) {
    ${$key} = $value;
}
//echoalert($_JS);
// connect database
$daba = new database();
$daba->connect("localhost", "iggmp", "1s87J37r0");
$daba->select("thesaurus");
$exportString = export::print_tree($id, $type);
if ($type == "adlib") {
    $extension = ".xml";
} else {
    $extension = ".csv";
}
$path = "import/export" . user::id() . $extension;
$fHandle = fopen($path, "w");
fputs($fHandle, utf8_decode($exportString));
fclose($fHandle);
echo "<a href='{$path}'>{$type} herunterladen</a>";
?>
</body>