Example #1
0
function record($id, $termType)
{
    $uses = "";
    $term = thesaurus::get_name($id);
    $uses = extract_pattern($term, "/\\(BS[: ](?<use>.*)\\)/");
    $recordArray = array();
    $record = new simpleXmlElement("<record />");
    // check if term already exists
    // define array for record creation
    $recordArray['input.name'] = "Thesaurus Redaktion";
    $recordArray['input.date'] = date("Y-m-d", time());
    $recordArray['input.time'] = date("h:i:s", time());
    $recordArray['term.type'] = $termType;
    $recordArray['term.status'] = thesaurus::get_status_name(thesaurus::get_status($id));
    $recordArray['term'] = $term;
    $recordArray['notes'] = thesaurus::get_comment($id);
    $recordArray['broader_term'] = thesaurus::get_parent($id);
    //  $recordArray['narrower_term'] = thesaurus::get_child($id);
    $recordArray['related_term'] = thesaurus::get_assoc($id);
    $recordArray['used_for'] = $uses;
    xml_insert($record->record, create_record($recordArray, $termType));
    return $record;
}
Example #2
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;
 }