function action($_arg) { //------------------------------------------------------------------------------ // extrace action from coordinate system while ($entry = each($_arg)) { $argArray = explode("_", $entry[key]); if (count($argArray) > 1) { $indexString = $argArray[0]; $valueString = $argArray[1]; $_arg[$indexString] = $valueString; if (isset($argArray[2])) { $_arg['_ID'] = $argArray[2]; } } } //echoalert($_arg); //echoalert($_SESSION); //------------------------------------------------------------------------------ // parse reset value if ($_arg[reset]) { $_arg = array(); session::destroy(searchshow); session::destroy(show); session::destroy(search); session::destroy(searchtype); session::destroy(searchcom); session::destroy(searchorder); session::destroy(searchString); session::destroy(searchexact); session::destroy(searchstart); session::destroy(searchowner); session::destroy(searchentrytype); session::destroy(searchstatus); } //------------------------------------------------------------------------------ // parse action parameter switch ($_arg[action]) { //------------------------------------------------------------------------------ // login / out case login: // login user user::login($_arg[user], $_arg[password]); // restore program status if new session restore_status(); // reset linking session::destroy("linkaction"); session::destroy("link"); break; case logout: // logout user user::logout(); break; case changedo: // change password if ($password = $_GET[password]) { database::query("UPDATE user SET password='******' WHERE ID='" . session::get("user") . "'"); echojavascript("Passwort erfolgreich geändert"); } break; //------------------------------------------------------------------------------ // inherit entrytype to children //------------------------------------------------------------------------------ // inherit entrytype to children case inherit: $childArray = thesaurus::get_child($_arg[id]); foreach ($childArray as $entry) { database::query("UPDATE entry SET entrytype={$_arg['entrytype']} WHERE ID={$entry}"); } break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case update: if ($_arg[orderdefault]) { session::set(orderdefault, $_arg[id]); } elseif (isset($_arg[orderdefault])) { session::destroy(orderdefault); } break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case edit: session::set("edit", TRUE); session::set("show", $_arg[id]); session::destroy("searchshow"); break; case noedit: session::destroy("edit"); break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case open: session::open($_arg[id]); break; case close: session::close($_arg[id]); break; case closeall: session::close_all(); break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case deleteid: end_link(); hide(); database::delete($_arg[id]); break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case suchen: if (!$_arg[searchString] and ($_arg[searchowner] or $_arg[searchtype] or $_arg[searchstatus])) { $_arg[searchString] = "%"; } if ($_arg[searchString]) { session::set("searchshow", true); } // show search result session::set("search", $_arg[searchString]); session::set("searchcom", $_arg[searchcom]); session::set("searchorder", $_arg[searchorder]); session::set("searchentrytype", $_arg[searchentrytype]); session::set("searchstatus", $_arg[searchstatus]); if ($_arg[searchowner]) { session::set("searchowner", $_arg[searchowner]); } else { session::destroy("searchowner"); } switch ($_arg[searchtype]) { case 0: session::destroy("searchexact"); session::destroy("searchstart"); break; case 1: session::destroy("searchexact"); session::set("searchstart", TRUE); break; case 2: session::destroy("searchstart"); session::set("searchexact", TRUE); break; } break; case hidesearch: session::destroy(searchshow); break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case show: session::destroy("searchshow"); $_arg[linkaction] = ""; if ($_arg[id] == NULL) { break; } elseif ($_arg[id] > 0) { session::set("show", $_arg[id]); break; } else { session::delete("show"); break; } break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case swap: if ($_arg[id]) { thesaurus::swap_link($_arg[id], $_arg[_ID]); } break; case change: if ($_arg[id]) { // thesaurus::change_link($_arg); } break; case add: // add new descriptor session::destroy("show"); session::destroy("searchshow"); // session::set("",1); break; // clean database // clean database case correct: thesaurus::validate(true); echoalert("Datenbank bereinigt"); break; //------------------------------------------------------------------------------ // open hyrarchy down to selected entry //------------------------------------------------------------------------------ // open hyrarchy down to selected entry case showhyrarchy: if ($_arg[id]) { $hyrarchyArray = thesaurus::get_hyrarchy($_arg[id]); // don't open selected entry // array_pop($hyrarchyArray); foreach ($hyrarchyArray as $entry) { // echo $entry . " "; echo session::open($entry); } session::set("hyrarchy", TRUE); // hide search window session::destroy("searchshow"); // if nothing selected for display, show ID if (!session::get(show)) { session::set("show", $_arg[id]); } break; } //------------------------------------------------------------------------------ // debug on/off //------------------------------------------------------------------------------ // debug on/off case debugon: system::setval(debug, TRUE); break; case debugoff: system::setval(debug, FALSE); // legend on/off // legend on/off case legendon: session::set("legend", TRUE); break; case legendoff: session::destroy("legend"); break; // display / hide non descriptors // display / hide non descriptors case toggleND: if (session::get("descriptor")) { session::destroy("descriptor"); } else { session::set("descriptor", TRUE); } break; // display / hide orders // display / hide orders case toggleVI: if (session::get("visible")) { session::destroy("visible"); } else { session::set("visible", TRUE); } break; // toggle tooltips on/off // toggle tooltips on/off case off: session::set("tooltips", TRUE); break; case on: session::destroy("tooltips"); break; // toggle hyrarchy // toggle hyrarchy case hyrarchyon: session::set("hyrarchy", TRUE); break; case hyrarchyoff: session::set("hyrarchy", FALSE); break; } //------------------------------------------------------------------------------ // parse linkaction parameter switch ($_arg[linkaction]) { // link case link: session::set("link", $_arg[id]); session::set("linkaction", $_arg[linkaction]); session::set("linktype", $_arg[linktype]); break; // execute linking // execute linking case linkdo: switch (session::get('linkaction')) { case link: database::parent_insert(session::get("link"), $_arg[id], session::get("linktype")); session::set("show", session::get("link")); // set display to linked objects // with BS set linked descriptor to "no descriptor" if (session::get("linktype") == 2) { database::set_desc($_arg[id], 0); } // session::destroy("link"); // end linking break; case change: database::link_change(session::get('linkparent'), session::get('link'), $_arg['id']); // parent,oldlink,newlink break; } break; case linkend: end_link(); break; // unlink // unlink case unlink: if ($_arg[id]) { database::parent_delete(session::get("show"), $_arg[id]); } break; // change OB // change OB case change: if ($_arg[id]) { session::set("link", $_arg[id]); session::set("linkaction", $_arg[linkaction]); session::set("linkparent", $_arg[_ID]); session::set("linktype", $_arg[linktype]); } break; } // TEMP SETTINGS // if not link rights, set descriptor and visible to true if (!right::link()) { session::set(descriptor, FALSE); } //if (!right::link()) session::set(visible,TRUE); // save program status save_status($_SESSION); }
function display($id, $linktype) { echo "<table width='100%'>"; echo "<tr>"; echo "<td>"; // open tree to selected parent action::open_tree(); // open deskriptor action::show(); if (right::link()) { // swap direktion for equivalent links if ($linktype == 2 and right::write()) { action::swap($id); } // change OB if ($linktype == 1 and right::write()) { action::change($id); } } echo "</td>"; if (right::link()) { echo "<td align='right'>"; if (right::write()) { // make new parent link action::add_link($id, $linktype); if ($linktype == 1) { $minimum = 1; } else { $linktype == 0; } // unlink selected parent if (thesaurus::parent_num($id) > $minimum) { action::unlink(); } } echo "</td>"; } echo "</tr>"; echo "</table>"; }
function header() { echo "<b class='big'>"; if (!thesaurus::is_thesaurus(session::get("link"))) { echo form::link("", "Hierarchie", "index.php?action=show&id=0&linkaction=linkdo"); } else { echo "Hierarchie"; } // title line echo "</b>"; // insert thesaurus if (right::link()) { // new only if write permission echo form::link("add", "add", "index.php?action=add&parent=0", "add-thesaurus"); } // close complete tree action::closeall(); // Show Link activity if ($linkID = session::get("link")) { echo "<br><i><span class='red'>"; $linktype = thesaurus::get_type_short(session::get("linktype")); if (session::get('linkaction') == "change") { $linkArray = thesaurus::get_descriptor($linkID); $parentArray = thesaurus::get_descriptor(session::get("linkparent")); echo "<b>" . $linktype . " '" . $linkArray[name] . "'</b> von <b>'" . $parentArray[name] . "'</b> ändern"; } else { $linkArray = thesaurus::get_descriptor($linkID); echo "Neuen <b>" . $linktype . "</b> für <b>'{$linkArray['name']}'</b> verlinken"; } echo "</span><span class='normal'><br>Aktion beenden "; echo form::link("delete", "end", "index.php?linkaction=linkend", "end-linking"); echo "</i>"; } echo "<hr align='left' width='400px'>"; }
$_JS = 0; ?> </noscript> </head> <body> <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div> <?php //echoalert($_JS); // connect database $daba = new database(); $daba->connect("localhost", "iggmp", "1s87J37r0"); $daba->select("thesaurus"); if (right::link()) { thesaurus::validate(); } // show login or logged user user::show(); // headline ?> <div id='header'> <a href='index.php'>OpenThesaurus</a><br> <?php // show count of entries echo " <i class='normal'>("; echo database::count() . " Einträge mit "; echo database::linkcount() . " Verknüpfungen"; echo ")</i>";
function validate($action = "") { // check entries with undefined links $sqlRef = database::query("SELECT * FROM parent"); $tempString = ""; // loop over all link entries while ($entry = mysql_fetch_array($sqlRef)) { if (!$action) { $parentName = thesaurus::get_name($entry[parent]); $childName = thesaurus::get_name($entry[child]); if (!thesaurus::get_descriptor($entry[parent]) and $entry[parent] != 0) { $tempString .= "Oberbegriff {$entry['parent']} von <b>'{$childName}'</b> <i>({$entry['child']})</i> existiert nicht<br>"; } if (!thesaurus::get_descriptor($entry[child])) { $tempString .= "Unterbegriff {$entry['child']} von <b>'{$parentName}'</b> <i>({$entry['parent']})</i> existiert nicht<br>"; } } else { if ((!thesaurus::get_descriptor($entry[parent]) or !thesaurus::get_descriptor($entry[child])) and $entry[parent] != 0) { database::query("DELETE FROM parent WHERE ID={$entry['ID']}"); } } // check crosslinks between thesauri if (thesaurus::get_thesaurus($entry[parent]) and thesaurus::get_thesaurus($entry[parent]) != thesaurus::get_thesaurus($entry[child])) { $crossString .= form::link("", $entry[parent], "index.php?action=show&id={$entry['parent']}") . " <=> " . form::link("", $entry[child], "index.php?action=show&id={$entry['child']}") . " link in different thesauri<br>"; } } // display error messages if (right::link() and ($tempString or $crossString)) { echo "<div id='alert' class='red'>"; if ($tempString) { echo "<b>OB / UB Fehler</b><br>{$tempString}<br>"; echo "Datenbank bereinigen "; echo form::link("delete", "Datenbank bereinigen", "index.php?action=correct", "correct", ""); } // display error message if ($crossString) { echo "<b>Crosslink Fehler</b><br>{$crossString}<br>"; // echo "Datenbank bereinigen "; // echo form::link("delete","Datenbank bereinigen","index.php?action=correct","correct",""); } echo "</div>"; } // rewrite thesaurus links $sqlRef = database::query("SELECT * FROM entry"); while ($entry = mysql_fetch_array($sqlRef)) { $tempArray = thesaurus::get_hyrarchy($entry[ID]); if (is_array($tempArray)) { $thesaurus = $tempArray[0]; } else { $thesaurus = $tempArray; } database::query("UPDATE entry SET thesaurus='{$thesaurus}' WHERE ID='{$entry['ID']}'"); } }
function insert_entry($_arg, $errorArray, $value = "") { if ($_arg[action] == 'add' or $_arg[action] == 'insert' and $errorArray) { // set default value if ($value) { $_arg[name] = $value; } echo "<form name='descriptor' method='get' action='index.php'>"; $name = thesaurus::name($_arg[parent]); if ($name) { echo "<p><b>Neuen Unterbegriff in '<span class='red'>"; echo "<a href='index.php?action=show&id={$_arg['parent']}'>{$name}</a>"; echo "</span>' "; if (right::link()) { echo "anlegen"; } else { echo "vorschlagen"; } echo "</b></p>"; } else { echo "<p><b>Neuen Thesaurus anlegen</b></p>"; } $error = $errorArray[name]; // name of new descriptor echo form::field("text", "name", $_arg[name], 30, "class='{$error}'", "<span class='small'>Name</span><br>", "", "name-field"); switch ($error) { case exist: echo "<br><b class='exist'>Eintrag existiert schon</b>"; echo form::link("", " Eintrag ansehen", "index.php?action=suchen&searchString={$_arg['name']}&searchtype=2", "showexist"); break; case alike: /* echo "<br><b class='exist'>Ähnliche Einträge existiert schon</b>"; echo form::link(""," Einträge ansehen","index.php?action=suchen&searchString=$_arg[name]&searchtype=1","showalike"); */ break; default: break; } echo "<br>"; // type of descriptor /* $typeArray = thesaurus::get_type_list(); $entryType = thesaurus::get_entrytype($_arg[parent]); echo form::selector("entrytype",$typeArray,1,"",$entryType[entrytype],"<span class='small'>Begriffstype</span><br>","","entrytype"); */ echo "<br>"; // status of descriptor if (right::write()) { $statusArray = thesaurus::get_status_list(); echo form::selector("status", $statusArray, 1, "", thesaurus::get_status($id), "<span class='small'>Status</span><br>", "", "statustype"); } else { echo "<span class='small'>Status</span><br><span class='normal'>" . thesaurus::get_status_name(thesaurus::newstatus()) . "</span>"; echo form::field("hidden", "status", thesaurus::newstatus()); } echo "</p>"; $error = $errorArray[comment]; // comment field echo form::textfield("comment", $_arg[comment], 45, 3, "class='{$error}'", "Bemerkungen<br>", "", "comment-field"); echo form::field("submit", "", "anlegen", "", "", "", "", "new"); echo form::field("hidden", "parent", $_arg[parent]); echo form::field("hidden", "id", $_arg[id]); echo form::field("hidden", "action", "insert"); echo form::field("hidden", "type", 1); echo "</form>"; } }