mirror of
https://github.com/php/php-src.git
synced 2024-10-07 01:36:14 +00:00
201 lines
6.3 KiB
Plaintext
201 lines
6.3 KiB
Plaintext
<?
|
|
$id = 190867; // A plain/text document
|
|
$collid = 169828; // A collection
|
|
$query = "Name=m*"; // Search query for test_9
|
|
$host = "gehtnix";
|
|
$username = "steinm";
|
|
$password = "akli9132";
|
|
|
|
$connect = hw_connect($host, 418, $username, $password);
|
|
if(hw_error($connect)) {
|
|
echo "ERROR: ".hw_errormsg($connect)."\n";
|
|
exit;
|
|
}
|
|
|
|
// Set all test to 'yes' if they shall be executed
|
|
$test_1 = "yes"; // Get the text document with id $id and output it
|
|
$test_2 = "yes"; // Check if id $id is in $collid
|
|
$test_3 = "yes"; // Convert object record to object array and back
|
|
$test_4 = "yes"; // Get object record of object with id $id
|
|
$test_5 = "yes"; // List children of $collid
|
|
$test_6 = "yes"; // List parents of $id
|
|
$test_7 = "yes"; // Insert a new text document
|
|
$test_8 = "yes"; // Remove the just inserted text document
|
|
$test_9 = "yes"; // Searching for objects with Name $query
|
|
|
|
/* Lists an object array
|
|
*/
|
|
function list_attr($attributes) {
|
|
global $imagepath;
|
|
for($i=0; $i<count($attributes); $i++) {
|
|
$key = key($attributes);
|
|
switch($key) {
|
|
case "Title":
|
|
case "Description":
|
|
$title_arr = $attributes[$key];
|
|
$cj = count($title_arr);
|
|
printf("%s = ", $key);
|
|
for($j=0; $j<$cj; $j++) {
|
|
$tkey = key($title_arr);
|
|
switch($tkey) {
|
|
case "en":
|
|
$flagfile = "english.gif";
|
|
break;
|
|
case "ge":
|
|
$flagfile = "german.gif";
|
|
break;
|
|
case "du":
|
|
$flagfile = "dutch.gif";
|
|
break;
|
|
default:
|
|
$flagfile = "europe.gif";
|
|
}
|
|
printf("%s:%s; ", $tkey, $title_arr[$tkey]);
|
|
|
|
next($title_arr);
|
|
}
|
|
printf("\n");
|
|
break;
|
|
default:
|
|
printf("%s = %s\n", $key, $attributes[$key]);
|
|
}
|
|
next($attributes);
|
|
}
|
|
echo "\n";
|
|
}
|
|
|
|
// Here come the tests
|
|
if($test_1 == "yes") {
|
|
echo "TEST 1 ----------------------------------------------\n";
|
|
echo "Get the text document with id 0x".dechex($id)."\n";
|
|
$doc = hw_gettext($connect, $id);
|
|
if(hw_error($connect)) {
|
|
echo "ERROR: ".hw_errormsg($connect)."\n";
|
|
exit;
|
|
}
|
|
hw_output_document($doc);
|
|
echo "\n";
|
|
}
|
|
|
|
if($test_2 == "yes") {
|
|
echo "TEST 2 ----------------------------------------------\n";
|
|
echo "Checking if '$id' (0x".dechex($id).") is in collection '$collid (0x".dechex($collid).")'\n";
|
|
$incoll = hw_incollections($connect, array($id), array($collid), 0);
|
|
if(hw_error($connect)) {
|
|
echo "ERROR: ".hw_errormsg($connect)."\n";
|
|
exit;
|
|
}
|
|
for($i=0; $i<count($incoll); $i++)
|
|
echo $incoll[$i]."\n";
|
|
}
|
|
|
|
if($test_3 == "yes") {
|
|
echo "TEST 3 ----------------------------------------------\n";
|
|
echo "Convert an object array into an object record\n";
|
|
$objrec = hw_array2objrec(array("Title"=>"ge:Hier der Titel", "Author"=>"Hier der Autor"));
|
|
echo $objrec."\n";
|
|
$objrec .= "\nTitle=en:Here the title";
|
|
echo "Add another title and convert it back to an object array\n";
|
|
$objarr = hw_objrec2array($objrec);
|
|
list_attr($objarr);
|
|
}
|
|
|
|
if($test_4 == "yes") {
|
|
echo "TEST 4 ----------------------------------------------\n";
|
|
echo "Get the object array of document with id 0x".dechex($id)."\n";
|
|
$objrec = hw_getobject($connect, $id);
|
|
if(hw_error($connect)) {
|
|
echo "ERROR: ".hw_errormsg($connect)."\n";
|
|
exit;
|
|
}
|
|
$objarr = hw_objrec2array($objrec);
|
|
list_attr($objarr);
|
|
}
|
|
|
|
if($test_5 == "yes") {
|
|
echo "TEST 5 ----------------------------------------------\n";
|
|
echo "List the children of collection 0x".dechex($collid)."\n";
|
|
$children = hw_childrenobj($connect, $collid);
|
|
if(hw_error($connect)) {
|
|
echo "ERROR: ".hw_errormsg($connect)."\n";
|
|
exit;
|
|
}
|
|
$c_children = count($children) - 1;
|
|
for($i=0; $i<$c_children; $i++) {
|
|
$objarr = hw_objrec2array($children[$i]);
|
|
list_attr($objarr);
|
|
}
|
|
list_attr($children[$c_children]);
|
|
}
|
|
|
|
if($test_6 == "yes") {
|
|
echo "TEST 6 ----------------------------------------------\n";
|
|
echo "List the parents of object 0x".dechex($id)."\n";
|
|
$parents = hw_getparentsobj($connect, $collid);
|
|
if(hw_error($connect)) {
|
|
echo "ERROR: ".hw_errormsg($connect)."\n";
|
|
exit;
|
|
}
|
|
$c_parents = count($parents) - 1;
|
|
for($i=0; $i<$c_parents; $i++) {
|
|
$objarr = hw_objrec2array($parents[$i]);
|
|
list_attr($objarr);
|
|
}
|
|
list_attr($parents[$c_parents]);
|
|
}
|
|
|
|
if($test_7 == "yes") {
|
|
echo "TEST 7 ----------------------------------------------\n";
|
|
echo "Inserting a new text document into 0x".dechex($collid)."\n";
|
|
$objrec = "Type=Document\nDocumentType=text\nName=HWTest\nTitle=en:Component\nMimeType=text/plain\nAuthor=".$username;
|
|
$contents = "Ein bischen Text";
|
|
$doc = hw_new_document($objrec, $contents, strlen($contents)+1);
|
|
$objid = hw_insertdocument($connect, $collid, $doc);
|
|
if(hw_error($connect)) {
|
|
echo "ERROR: ".hw_errormsg($connect)."\n";
|
|
exit;
|
|
}
|
|
$objrec = hw_getobject($connect, $objid);
|
|
if(hw_error($connect)) {
|
|
echo "ERROR: ".hw_errormsg($connect)."\n";
|
|
exit;
|
|
}
|
|
$objarr = hw_objrec2array($objrec);
|
|
list_attr($objarr);
|
|
}
|
|
|
|
if($test_8 == "yes") {
|
|
echo "TEST 8 ----------------------------------------------\n";
|
|
echo "Removing text document just inserted\n";
|
|
$kk[0] = (int) $objid;
|
|
hw_mv($connect, $kk, $collid, 0);
|
|
if(hw_error($connect)) {
|
|
echo "ERROR: ".hw_errormsg($connect)."\n";
|
|
exit;
|
|
}
|
|
echo "If the document was really deleted you should see an error now\n";
|
|
$objrec = hw_getobject($connect, $objid);
|
|
if(hw_error($connect)) {
|
|
echo "ERROR: ".hw_errormsg($connect)."\n";
|
|
} else {
|
|
$objarr = hw_objrec2array($objrec);
|
|
list_attr($objarr);
|
|
}
|
|
}
|
|
|
|
if($test_9 == "yes") {
|
|
echo "TEST 9 ----------------------------------------------\n";
|
|
echo "Searching for objects with $query\n";
|
|
$objrecs = hw_getobjectbyqueryobj($connect, $query, -1);
|
|
$c_objrecs = count($objrecs) - 1;
|
|
echo "$c_objrecs found\n";
|
|
for($i=0; $i<$c_objrecs; $i++) {
|
|
$objarr = hw_objrec2array($objrecs[$i]);
|
|
list_attr($objarr);
|
|
}
|
|
list_attr($objrecs[$c_objrecs]);
|
|
}
|
|
|
|
hw_close($connect);
|
|
?>
|